Powerbuilder 12.5数据库连接初学者教程 [英] Powerbuilder 12.5 database connection beginner tutorials

查看:1291
本文介绍了Powerbuilder 12.5数据库连接初学者教程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Powerbuilder 12.5还是很陌生,我找不到关于SQL 2008的数据库管理的很多教程。我需要通过VB.NET vs2008中的代码连接到它

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 =数据源=服务器名;初始目录=用户;集成安全性=真实

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

推荐答案

数据窗口

PB的大多数数据库工作都是通过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).

然后,您可以在代码中通过datawindow控件检索数据并发出命令,它将自动为您处理插入,更新和删除sql语句。

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.

例如:

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) 

(有关括号中值的含义,请参阅PB帮助以获取更多信息)

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

数据库连接

PowerBuilder有一个内置事务对象,您可以使用它称为sqlca:

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; 

您可以断开连接:

disconnect using sqlca; 

这篇关于Powerbuilder 12.5数据库连接初学者教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆