powerbuilder连接mysql,Powerbuilder 12.5数据库连接初学者教程

I am fairly new to powerbuilder 12.5 and i cant find much tutorials on database management on SQL 2008. I need to connect to it via code like in VB.NET vs2008

Dim con As New SqlConnection

Con.connectionstring = "Data Source=servername;Initial Catalog=user;Integrated Security=True"

I need to select, insert, update and delete data...

Any help on code samples

解决方案

Datawindows

Most database work with PB is done using datawindows. After you create a new datawindow, you set up your select statement in it.

Then you add a datawindow control to your form and set the control to use the datawindow that you created (using the properties window or even in code).

Then in your code you can retrieve the data and issue commands via the datawindow control and it will automatically handle the insert, update and delete sql statements for you.

For example:

dw_1.retrieve() // dw_1 is the name of the datawindow control

// insert a row

dw_1.insertrow(0)

// delete a row

dw_1.deleterow(1)

// update all changed rows

dw_1.update(true, true)

(see the PB help for more info on what the values in parenthesis mean)

DB connections

PowerBuilder has a built-in transaction object that you can use called sqlca:

sqlca.dbms = "SNC SQL Native Client(OLE DB)"

sqlca.servername = "servername"

sqlca.dbparm = "Database='user',Provider='SQLNCLI10',Identity='@@IDENTITY',TrustedConnection=1"

Then to connect to this database you do:

connect using sqlca;

You can disconnect with:

disconnect using sqlca;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值