在PowerBulider中根據三個下拉表(dropdownlist)對資料視窗進行查詢的按鈕的代碼怎么寫啊?
我想在視窗中建立三個下拉表和一個檢索按鈕,根據我在下拉表選擇的內容當點擊檢索按鈕時,資料視窗就會顯示我選擇的資料,請問這個檢索按鈕的代碼怎么寫啊?!
uj5u.com熱心網友回復:
(1)、條件構造中第一個下拉串列代碼如下:/*ddlb_column的相應項改變時將觸發selectionchanged事件,因此在該事件中
實作取相應列所對應的值并將其加入到ddlb_value中。其實作是通過SQL陳述句
取出列名所對應的值,并使用datastore記錄其值*/
string temp,ls_sql_syntax,err_str
int j,k
//宣告資料存盤物件
datastore lds_data
//洗掉ddlb_value中的全部專案
do while(ddlb_value.totalitems()>0)
ddlb_value.deleteitem(1)
loop
//獲得index對應的列的欄位名,如student.name,其中student為表名
//name為欄位名。index為本事件傳遞的引數,代表ddlb_column中串列項
//的索引號,也即該列在資料視窗中的列號
temp=dw_name.describe(columnname[index]+".dbname")
//形成select陳述句語法,如"select distinct name from student"
//distinct 起到抑制某列的重復值,相同的值只保留一個
ls_sql_syntax='select distinct '+columnname[index]+' from ' &
+left(temp,pos(temp,'.')-1)
//設定自動提交屬性,這對于SQLServer資料庫是必須的
sqlca.autocommit=true
//根據SQL Select陳述句生成資料視窗物件的源代碼
ls_sql_syntax=sqlca.syntaxfromsql(ls_sql_syntax,"",err_str)
//創建存盤程序
lds_data=https://bbs.csdn.net/topics/create datastore
//根據SQL Select陳述句生成資料視窗物件的源代碼,創建資料視窗物件
lds_data.create(ls_sql_syntax)
//設定事務物件,檢索資料
lds_data.settransobject(sqlca)
j=lds_data.retrieve()
sqlca.autocommit=false
//通過回圈讀取與資料存盤相關聯的資料視窗物件中的資料
//data[k,1]可理解為資料視窗物件中的第k行第1列的資料值
for k=1 to j
temp=string(lds_data.object.data[k,1])
//如果是日期型資料,轉換為標準格式
if columntype[index]='datetime' or &
columntype[index]='smalldatetime' or &
columntype[index]='date' then &
temp=string(lds_data.object.data[k,1],'yyyy-mm-dd')
if isnull(temp) or temp='' then continue
//將檢索到的ddlb_column欄位的所有可能取值添加到ddlb_value
ddlb_value.additem(temp)
next
uj5u.com熱心網友回復:
簡單的做法就是在datawindow上加這3個檢索引數,在按鈕里分別去取3個下拉里的資料,作為檢索引數
uj5u.com熱心網友回復:
定義三個實體變數,如is_1,is_2,is_3。將ddlb_1.text 賦予is_1,ddlb_2.text賦予is_2,ddlb_3.text賦予is_3;
檢索按鈕中寫:
dw_1.settransobject(sqlca)
dw_1.retrieve(is_1,is_2,is_3)
uj5u.com熱心網友回復:
把下拉表的值作為過慮條件。例如過慮股室和單位
String Ls_Filter
Ls_Filter = '股室 = 國庫股 and 單位 = 財政廳'
dw_1.SetFilter(Ls_Filter)
dw_1.Filter()
uj5u.com熱心網友回復:
把下拉表的值作為過慮條件。例如過慮股室和單位
String Ls_Filter
Ls_Filter = '股室 = 國庫股 and 單位 = 財政廳'
dw_1.SetFilter(Ls_Filter)
dw_1.Filter()
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/96437.html
標籤:腳本語言
