資料查詢的間題~ |
答題得分者是:yachanga
|
jacksonhuang
一般會員 發表:26 回覆:22 積分:9 註冊:2004-04-20 發送簡訊給我 |
|
yachanga
資深會員 發表:24 回覆:335 積分:296 註冊:2003-09-27 發送簡訊給我 |
Hi jacksonhuang:
請試試可不可行: ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Text = "select * from Account_List where U_ID = '"+ this->Edit1->Text +"'";
ADOQuery1->Open();
|
lu
高階會員 發表:11 回覆:189 積分:195 註冊:2003-11-19 發送簡訊給我 |
引言: ADOQuery1->Close(); ADOQuery1->SQL->Clear(); ADOQuery1->SQL->Text = "select * from Account_List where U_ID = '" this->Edit1->Text "'"; ADOQuery1->Open(); ADOQuery1->Last; // 這樣可確保recordCount是正確的 IF ADOQUERY1->RECORDCOUNT =0恩...這樣也可以,但是有點小問題(yachanga 對不起嘿,偶沒有任何不敬的意思),如果你的結果是很多筆資料時,ADOQuery1->Last();,要花上很久的時間喔,原因嗎.....之前有大大討論過 如果只是要檢查有沒有找到資料,偶個人建議用這樣,如下面藍色程式碼 ADOQuery1->Close(); ADOQuery1->SQL->Clear(); ADOQuery1->SQL->Text = "select * from Account_List where U_ID = '" this->Edit1->Text "'"; ADOQuery1->Open(); if (ADOQuery1->Eof && ADOQuery1->Bof) { //找不到資料 }這是MSDN的說明,參考看看 If the data source returns no records, the provider sets both the BOF and EOF properties to True, and the current record position is undefined. You can still add new data to this empty Recordset object if the cursor type allows it. 不過偶個人都偷懶,都只檢查EOF而已....< > <>最後請各位大大原諒,偶真的沒有任何攻擊、批評的意思喔,偶只是提供一點小小的、微不足道的使用經驗而已>< > ========================= <>大家一起快樂寫程式> 發表人 - lu 於 2004/04/29 13:42:35 |
yachanga
資深會員 發表:24 回覆:335 積分:296 註冊:2003-09-27 發送簡訊給我 |
引言: 恩...這樣也可以,但是有點小問題(yachanga 對不起嘿,偶沒有任何不敬的意思)[/bue],如果你的結果是很多筆資料時,ADOQuery1->Last();,要花上很久的時間喔,原因嗎.....之前有大大討論過 如果只是要檢查有沒有找到資料,偶個人建議用這樣,如下面藍色程式碼ADOQuery1->Close(); ADOQuery1->SQL->Clear(); ADOQuery1->SQL->Text = "select * from Account_List where U_ID = '" this->Edit1->Text "'"; ADOQuery1->Open(); if (ADOQuery1->Eof && ADOQuery1->Bof) { //找不到資料 }這是MSDN的說明,參考看看 If the data source returns no records, the provider sets both the BOF and EOF properties to True, and the current record position is undefined. You can still add new data to this empty Recordset object if the cursor type allows it. 不過偶個人都偷懶,都只檢查EOF而已....< > <>最後請各位大大原諒,偶真的沒有任何攻擊、批評的意思喔,偶只是提供一點小小的、微不足道的使用經驗而已>< > ========================= [> > 謝謝 lu 大大的指教 ,又多學了一招 我在實務上還有用過另一招, 不好意思又獻醜了 如果 class="code"> if (ADOQuery1->FieldbyName('U_ID')->asString='') { //找不到資料 } ~悠遊法國號~ |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |