線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1967
推到 Plurk!
推到 Facebook!

在動態的tquery上新增一個param....

 
daimay0127
一般會員


發表:5
回覆:9
積分:2
註冊:2006-07-27

發送簡訊給我
#1 引用回覆 回覆 發表時間:2006-11-23 16:56:07 IP:61.218.xxx.xxx 未訂閱
請教各位大師:
我用下列語法動態CREATE一個Tquery;
Var
Stemp : Tquery;
begin
Stemp := Tquery.Create(self);
stemp.sql.text := 'select * from details where order_no := order_no'
stemp.open;
end;
請問?如果我想在這個動態的Tuery設一個叫order_no的傳入值
語法該怎麼寫呢?
謝謝
daimay
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#2 引用回覆 回覆 發表時間:2006-11-23 17:38:48 IP:210.65.xxx.xxx 未訂閱
....
stemp.sql.text := 'select * from details where order_no = :p_order_no'
stemp.Prepare;
stemp.ParamByName('p_order_no').AsString := PutYourValueHere;
stemp.Open;
....


Fishman
------
Fishman
daimay0127
一般會員


發表:5
回覆:9
積分:2
註冊:2006-07-27

發送簡訊給我
#3 引用回覆 回覆 發表時間:2006-11-23 19:27:30 IP:218.170.xxx.xxx 未訂閱
感謝fishman大師
請問Prepare是什麼意思?!
不好意思,我是菜鳥....
daimay0127

Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#4 引用回覆 回覆 發表時間:2006-11-24 12:37:21 IP:210.65.xxx.xxx 未訂閱
編輯程式碼時,游標停放於該處,按下F1即可看到說明,Delphi 說明如下:
TQuery.Prepare
Sends a query to the Borland Database Engine (BDE) and the server for optimization prior to execution.
procedure Prepare;
Description
Call Prepare to have the BDE and a remote database server allocate resources for the query and to perform additional optimizations. Calling Prepare before executing a query improves application performance.
Delphi automatically prepares a query if it is executed without first being prepared. After execution, Delphi unprepares the query. When a query will be executed a number of times, an application should always explicitly prepare the query to avoid multiple and unnecessary prepares and unprepares.
Preparing a query consumes some database resources, so it is good practice for an application to unprepare a query once it is done using it. The UnPrepare method unprepares a query.
Note: When you change the text of a query at runtime, the query is automatically closed and unprepared.



Fishman
------
Fishman
daimay0127
一般會員


發表:5
回覆:9
積分:2
註冊:2006-07-27

發送簡訊給我
#5 引用回覆 回覆 發表時間:2006-11-24 20:50:29 IP:218.170.xxx.xxx 未訂閱
感謝fishman大師賜教
我是個菜鳥,非常抱歉....
daimay

系統時間:2024-04-19 8:32:58
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!