Powerbuilder 12.5 database connection beginner tutorials

谁说胖子不能爱 提交于 2019-12-22 00:27:22

问题


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


回答1:


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; 


来源:https://stackoverflow.com/questions/11282239/powerbuilder-12-5-database-connection-beginner-tutorials

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