Powerbuilder练级攻略002_datawindow
- 新建一个目录,如D:\pb_project\tutorial\p013_dw
- File-New-Workspace-OK,选中D:\pb_project\tutorial\p013_dw,打开,文件名输入p013_dw,保存
- File-New-Target-Application-OK,Application Name输入p013_app,Finish
- File-New-DataWindow-Grid-OK-SQL Select,在Select Tables对话框里选中想要查询的表,点Open,选中需要的列
- Design-Retrieval Arguments在Name里填想根据哪些查询的列名,如barcode,选Type为对应的类型,如String,点OK
- 在Table Layout里,点Column的第一行,点后面的倒三角,选中BARCODE,在Operator里选=,在Value里右键选:barcode
点左上角的Return按钮,Next-Finish,然后可以修改列名和列宽.Ctl+S保存,命名为d_1,OK - 新建窗口,w_main,在w_main里添加一个CommandButton,Text修改成查询
- 新建窗口w_1,Insert-Control-DataWindow,默认名为dw_1,在DataObject里选中之前新建的数据窗口对象d_1,这样数据窗口
对象和数据窗口控制就关联起来了.在w_1里添加控件SingleLineEdit,再添加控件CommandButton,Text改成查询. - 双击p013_app图标,在open函数里输入,这是连数据库的代码,然后打开w_main窗口.
String ls_user,ls_dbms,ls_servername,ls_database,ls_pass,ls_dbparm ls_user = "developer" ls_dbms = "O10 Oracle10g (10.1.0)" ls_servername = "oracle82" ls_pass = "123456" Disconnect Using sqlca; //使用填入属性连接 sqlca.LogID = ls_user sqlca.DBMS = ls_dbms sqlca.ServerName = ls_servername sqlca.Database = ls_database sqlca.LogPass = ls_pass sqlca.DBParm = ls_dbparm Connect Using sqlca; open(w_main)
1.双击w_1的图标,在Event List里选中Open,双击,输入
dw_1.SetTransObject(SQLCA)
1.双击w_main的CommnadButton按钮,输入
Open(w_1)
1.双击w_1的CommnadButton按钮,输入
String ls_1 ls_1 = Trim(sle_1.text) dw_1.Retrieve(ls_1) sle_1.SetFocus()