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

编程入门 行业动态 更新时间:2024-10-28 16:28:38
本文介绍了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数据库连接初学者教程

本文发布于:2023-10-31 00:44:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544489.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:初学者   数据库连接   教程   Powerbuilder

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!