基础·通过代码构建简单DW

本文介绍了如何通过PowerBuilder的Transaction对象的SyntaxFromSQL方法,根据SQL SELECT语句生成DataWindow源代码,然后利用DataWindow的Create方法创建动态DataWindow对象。同时,详细讲解了SetTransObject和Retrieve方法的用法,用于设置数据窗口的事务对象并从数据库检索数据。

[参考]:《Power Builder Help》(8.0)

Objects and Controls —— System Object Properties, Events, and Functions —— Transaction object

DataWindow Reference —— Methods for the DataWindow Control —— Create method

DataWindow Reference —— DataWindow Object Properties —— Controls in a DataWindow and their properties —— Properties for the DataWindow object

 

 

SyntaxFromSQL

Description: Generates DataWindow source code based on a SQL SELECT statement.

Syntax: transaction.SyntaxFromSQL(sqlselect,presentation,err)

Argument

transaction: The name of a connected transaction object

sqlselect: A string whose value is valid SQL SELECT statement

presentation: A string whose value is the default presentation style you want for the DatWindow.The simple format is: Style(Type=presentationstyle)

Keywords are: (Default) Tabular

                        Grid

                        Form(for freeform)

                        Graph

                        Group

                        Label

                        Nup

err: A string variable to which PowerBuilder will assign any error message that occur

Return value

string

""        —— error occurs

NULL   —— argument's value is NULL

 

 

Create method (DataWindows)

Description: Creates a DataWindow object using DataWindow source code and puts that object in the specified DataWindow control or DataStore object. This dynamic DataWindow object does not become a permanent part of the application source library.

Syntax: integer dwcontrol.Create(string syntax{,string errorbuffer})

Argument

syntax: A string whose value is the DataWindow source code that will be used to create the DataWindow object

errorbuffer: The name of a string that will hold any error message that occur.

 

 

Table.property

Description: Properties for the DataWindow's DBMS connection.

Syntax: dw_control.Object.DataWindow.Table.property

(表的属性很多,在此不列举,请参考帮助)

 

 

SetTransObject method (DataWindows)

Description: Causes a DataWindow control or DataStore to use a programer-specified transaction object.

Syntax: integer dwcontrol.SetTransObject(transaction transaction)

Return value

 1      —— succeeds

-1      —— error occurs

NULL —— argument's value is NULL

 

 

Retrieve method (DataWindows)

Description: Retrieves rows from the database for a DataWindow control or DataStore.

Syntax: long dwcontrol.Retrieve({any argument,any argument ...})

Return value

The number of rows displayed —— succeeds

-1                                             —— fails

 

 

[简单示例]:

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值