//取得關鍵字的字段類型
ls_type1 = dw_base.Describe(""+scolumnname+".ColType")
ls_type2 = dw_base.Describe(""+sDispColumn+".ColType")
sdbColumnName=dw_base.Describe(""+scolumnname+".dbName")//關鍵字的字段名 Modify By GangL 04/12/06 PM 2:17
sdbDispColumn=dw_base.Describe(""+sDispColumn+".dbName")
long ll_found
IF not(isnull(ls_keyword) or ls_keyword = '') then
IF ls_type1 = 'long' THEN
ll_found = dw_base.Find(""+sColumnName+" = "+ls_keyword+"",1,dw_base.RowCount())
ELSE
ll_found = dw_base.Find(""+sColumnName+" = '"+ls_keyword+"'",1,dw_base.RowCount())
END IF
dw_base.ScrollToRow(ll_found)
dw_base.SetRow(ll_found)
sle_1.setfocus()
PB數據窗口使用SetSqlSelect()函數應注意的問題
Limitations to using SetSQLSelectUse SetSQLSelect only if the data source for the DataWindow object is a SQL SELECT statement without retrieval arguments and you want PowerBuilder to modify the update information for the DataWindow object:
dw_1.Modify("DataWindow.Table.Select='select...'")
Modify will not verify the SELECT statement or change the update information, making it faster but more susceptible to user error. Although you can use Modify when arguments are involved, it is not recommended because of the lack of checking.
在腳本中修改數據窗口語法時,如果數據窗口沒有檢索條件,可以使用Getsqlselect讀取sql語句,修改為自己需要的sql語句后可用Setsqlselect重新設置查詢條件;也可以用MODIFY()函數修改,如設置不同的where條件,另外設置過后要恢復原來數據窗口的sql語句。
如果有檢索條件就不能用setsqlselect,
只可以用dw_1.Modify("DataWindow.Table.Select='select...'")
Eg:
ls_original=dw_1.getsqlselect()
if rb_3.checked=true then //base salary
ls_newsql=ls_original +" and (staff_master.monthly_pay=0 )"
else // fixed salary
ls_newsql=ls_original +" and (staff_master.monthly_pay in ('1','2','3') )"
end if
//int i
//i=dw_1.setsqlselect(ls_newsql) //// 數據窗口沒有設置檢索參數可以用setsqlselect
string ls_tmp
//ls_tmp="DataWindow.Table.Select='"+ls_newsql+"'"http://// 加入的where條件中用到單引號‘’這時dw_1.Modify("DataWindow.Table.Select='select...'")中的單雙引號應互換
ls_tmp='DataWindow.Table.Select="'+ls_newsql+'"'
ls_tmp=dw_1.Modify(ls_tmp) ////有檢索參數就只能用dw_1.modify()
dw_1.setsqlselect(ls_original)