資料(數據)庫相關問題,請問如何實現欄位中文檢索問題出錯的解決方法? |
答題得分者是:cashxin2002
|
BIG-ROM
初階會員 發表:94 回覆:91 積分:37 註冊:2005-04-16 發送簡訊給我 |
請問如何實現欄位中文檢索問題出錯的解決方法? procedure TINVOICE.SpeedButton1Click(Sender: TObject);
var
INVO: string;
begin
if (INVOICE.Text ='All Invoice') then
begin
LJSJK.INVOICE.Active:=false;
LJSJK.INVOICE.sql.Clear;
INVO:='select * from [INVOICE] order by INID Desc';
LJSJK.INVOICE.sql.Add(INVO);
LJSJK.INVOICE.Active :=True;
end else
begin
if (INVOICE.Text ='Invoice Number') and (not IsNumeric(Edit1.Text)) then
begin
showmessage('請輸入數字!');
end
else
begin
LJSJK.INVOICE.Active:=false;
LJSJK.INVOICE.sql.Clear;
INVO:='select * from [INVOICE] WHERE InvoiceNumber='+trim(edit1.Text)+' order by INID Desc';
LJSJK.INVOICE.sql.Add(INVO);
LJSJK.INVOICE.Active :=True;
begin
if (INVOICE.Text ='Attn') then
begin LJSJK.INVOICE.Active:=false;
LJSJK.INVOICE.sql.Clear;
INVO:='select * from [INVOICE] WHERE Attn like '+'''%'+edit1.text+'%'''+' order by INID Desc';
LJSJK.INVOICE.sql.Add(INVO);
LJSJK.INVOICE.Active :=True;
//*****問題出錯是當輸入中文字後就出現錯誤信息
end;
end;
end;
end;
end; 出錯如下圖:
寫程序——新問題會接踵而來!
|
cashxin2002
版主 發表:231 回覆:2555 積分:1937 註冊:2003-03-28 發送簡訊給我 |
您好﹗ 好像是程式邏輯上有些錯誤﹐改成如下試試﹕
procedure TINVOICE.SpeedButton1Click(Sender: TObject); var INVO: string; begin if (INVOICE.Text ='All Invoice') then begin LJSJK.INVOICE.Active:=false; LJSJK.INVOICE.sql.Clear; INVO:='select * from [INVOICE] order by INID Desc'; LJSJK.INVOICE.sql.Add(INVO); LJSJK.INVOICE.Active :=True; end else if (INVOICE.Text ='Invoice Number') and (Edit1.Text = '') then begin showmessage('請輸入數字!'); end else if (INVOICE.Text ='Invoice Number') and (Edit1.Text <> '') then begin LJSJK.INVOICE.Active:=false; LJSJK.INVOICE.sql.Clear; INVO:='select * from [INVOICE] WHERE InvoiceNumber='+trim(edit1.Text)+' order by INID Desc'; LJSJK.INVOICE.sql.Add(INVO); LJSJK.INVOICE.Active :=True; end else if (INVOICE.Text ='Attn') then begin LJSJK.INVOICE.Active:=false; LJSJK.INVOICE.sql.Clear; INVO:='select * from [INVOICE] WHERE Attn like '+'''%'+edit1.text+'%'''+' order by INID Desc'; LJSJK.INVOICE.sql.Add(INVO); LJSJK.INVOICE.Active :=True; end; end; 然后在Edit1的OnKeyPress事件中用程式碼限制只能輸入數字﹕ begin if Not (Key In ['0'..'9', #8]) then Key := #0; end;================================= 有空來瞅瞅我﹗因為我是您的朋友﹐有您真好﹗ ================================
------
忻晟 |
BIG-ROM
初階會員 發表:94 回覆:91 積分:37 註冊:2005-04-16 發送簡訊給我 |
您好,將上面程式碼貼上後按執行Search無反應了< > 加入這程式碼後無法輸入中文字了< >
---------------------------------
然後在Edit1的OnKeyPress事件中用程式碼限制只能輸入數字﹕
begin
if Not (Key In ['0'..'9', #8]) then
Key := #0;
end;
引言: .............. end;[/code] ================================= 有空來瞅瞅我﹗因為我是您的朋友﹐有您真好﹗ ================================寫程序——新問題會接踵而來! |
cashxin2002
版主 發表:231 回覆:2555 積分:1937 註冊:2003-03-28 發送簡訊給我 |
您好﹗
procedure TINVOICE.SpeedButton1Click(Sender: TObject); var INVO: string; begin if INVOICE.Text ='All Invoice' then begin LJSJK.INVOICE.Active:=false; LJSJK.INVOICE.sql.Clear; INVO:='select * from [INVOICE] order by INID Desc'; end else if INVOICE.Text ='Invoice Number' then begin if Edit1.Text = '' then begin showmessage('請輸入數字!'); Abort; end else begin LJSJK.INVOICE.Active:=false; LJSJK.INVOICE.sql.Clear; INVO:='select * from [INVOICE] WHERE InvoiceNumber='+trim(edit1.Text)+' order by INID Desc'; end; end else if INVOICE.Text ='Attn' then begin LJSJK.INVOICE.Active:=false; LJSJK.INVOICE.sql.Clear; INVO:='select * from [INVOICE] WHERE Attn like '+'''%'+edit1.text+'%'''+' order by INID Desc'; end; LJSJK.INVOICE.sql.Add(INVO); LJSJK.INVOICE.Active :=True; end;以下這段程式碼的目的就是限制使用者只能輸入數字﹐如果不需要﹐刪除這段程式碼即可﹒ begin if Not (Key In ['0'..'9', #8]) then Key := #0; end;================================= 有空來瞅瞅我﹗因為我是您的朋友﹐有您真好﹗ ================================
------
忻晟 |
BIG-ROM
初階會員 發表:94 回覆:91 積分:37 註冊:2005-04-16 發送簡訊給我 |
歹勢啦~~!!好厲害喔~ 經驗老道實在厲害!! 好在有您這麼熱心問題正式得到完滿的解決了,感謝您!!
引言: 您好﹗寫程序——新問題會接踵而來!procedure TINVOICE.SpeedButton1Click(Sender: TObject); var INVO: string; begin if INVOICE.Text ='All Invoice' then begin LJSJK.INVOICE.Active:=false; LJSJK.INVOICE.sql.Clear; INVO:='select * from [INVOICE] order by INID Desc'; end else if INVOICE.Text ='Invoice Number' then begin if Edit1.Text = '' then begin showmessage('請輸入數字!'); Abort; end else begin LJSJK.INVOICE.Active:=false; LJSJK.INVOICE.sql.Clear; INVO:='select * from [INVOICE] WHERE InvoiceNumber='+trim(edit1.Text)+' order by INID Desc'; end; end else if INVOICE.Text ='Attn' then begin LJSJK.INVOICE.Active:=false; LJSJK.INVOICE.sql.Clear; INVO:='select * from [INVOICE] WHERE Attn like '+'''%'+edit1.text+'%'''+' order by INID Desc'; end; LJSJK.INVOICE.sql.Add(INVO); LJSJK.INVOICE.Active :=True; end;以下這段程式碼的目的就是限制使用者只能輸入數字﹐如果不需要﹐刪除這段程式碼即可﹒begin if Not (Key In ['0'..'9', #8]) then Key := #0; end;================================= 有空來瞅瞅我﹗因為我是您的朋友﹐有您真好﹗ ================================ |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |