Powerbuilder 12.5 database connection beginner tutorials

南笙酒味 提交于 2019-12-04 18:39:08

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; 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!