全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1668
推到 Plurk!
推到 Facebook!

執行時發生錯誤的原因?

缺席
terrenceman
一般會員


發表:7
回覆:7
積分:2
註冊:2007-01-05

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-04-26 18:32:10 IP:140.115.xxx.xxx 訂閱
請各位大大幫我看看:

這是我在BCB中其中一個按鈕中的指令,當我編議程執行檔時,也都沒問題,可是當我執行時,點下此按鈕
卻告訴我說:『 Parameter ' TTNumber ' not found ! 』。請問這是什麼原因呢? 我找了好久都找不到那裡有問題~~
請各位幫我想想看,感恩啦~~~

void __fastcall TForm1::Button15Click(TObject *Sender)
{

TDateTime dt2 = Now();
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("UPDATE LineandFormulaandComment SET Line=SELine, Formula=SEFormula, Comment=SEComment, I=SEI, Date=SEDate, RGB100=SERGB100,");
ADOQuery1->SQL->Add("RGB010=SERGB010, RGB001=SERGB001, RGB111=SERGB111, RGB211=SERGB211, RGB121=SERGB121, RGB112=SERGB112 WHERE Number=TTNumber");
ADOQuery1->Parameters->ParamByName("TTNumber")->Value=StrToInt(StringGrid2->Cells[12][Row_Set_of_StringGrid2]);
ADOQuery1->Parameters->ParamByName("SELine")->Value=ComboBox1->Text;
ADOQuery1->Parameters->ParamByName("SEFormula")->Value=ComboBox2->Text;
ADOQuery1->Parameters->ParamByName("SEComment")->Value=Memo1->Text;
ADOQuery1->Parameters->ParamByName("SEI")->Value=ComboBox3->Text;
ADOQuery1->Parameters->ParamByName("SEDate")->Value=dt2;
ADOQuery1->Parameters->ParamByName("SERGB100")->Value=Edit1->Text;
ADOQuery1->Parameters->ParamByName("SERGB010")->Value=Edit2->Text;
ADOQuery1->Parameters->ParamByName("SERGB001")->Value=Edit3->Text;
ADOQuery1->Parameters->ParamByName("SERGB111")->Value=Edit4->Text;
ADOQuery1->Parameters->ParamByName("SERGB211")->Value=Edit5->Text;
ADOQuery1->Parameters->ParamByName("SERGB121")->Value=Edit6->Text;
ADOQuery1->Parameters->ParamByName("SERGB112")->Value=Edit7->Text;
ADOQuery1->ExecSQL();
}

Stallion
版主


發表:52
回覆:1600
積分:1995
註冊:2004-09-15

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-04-26 18:43:03 IP:211.22.xxx.xxx 未訂閱
不只一個吧!你的程式碼哪裡參考來的?沒用過動態參數嗎?參考一下下面改的地方,每一個變數前面都要加上冒號(:)
===================引 用 terrenceman 文 章===================
請各位大大幫我看看:

這是我在BCB中其中一個按鈕中的指令,當我編議程執行檔時,也都沒問題,可是當我執行時,點下此按鈕
卻告訴我說:『 Parameter ' TTNumber' not found ! 』。請問這是什麼原因呢? 我找了好久都找不到那裡有問題~~
請各位幫我想想看,感恩啦~~~

void __fastcall TForm1::Button15Click(TObject *Sender)
{

TDateTime dt2 = Now();
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("UPDATE LineandFormulaandComment SET Line=:SELine, Formula=:SEFormula, Comment=:SEComment, I=:SEI, Date=:SEDate, RGB100=:SERGB100,");
ADOQuery1->SQL->Add("RGB010=:SERGB010, RGB001=:SERGB001, RGB111=:SERGB111, RGB211=:SERGB211, RGB121=:SERGB121, RGB112=:SERGB112 WHERE Number=:TTNumber");
ADOQuery1->Parameters->ParamByName("TTNumber")->Value=StrToInt(StringGrid2->Cells[12][Row_Set_of_StringGrid2]);
ADOQuery1->Parameters->ParamByName("SELine")->Value=ComboBox1->Text;
ADOQuery1->Parameters->ParamByName("SEFormula")->Value=ComboBox2->Text;
ADOQuery1->Parameters->ParamByName("SEComment")->Value=Memo1->Text;
ADOQuery1->Parameters->ParamByName("SEI")->Value=ComboBox3->Text;
ADOQuery1->Parameters->ParamByName("SEDate")->Value=dt2;
ADOQuery1->Parameters->ParamByName("SERGB100")->Value=Edit1->Text;
ADOQuery1->Parameters->ParamByName("SERGB010")->Value=Edit2->Text;
ADOQuery1->Parameters->ParamByName("SERGB001")->Value=Edit3->Text;
ADOQuery1->Parameters->ParamByName("SERGB111")->Value=Edit4->Text;
ADOQuery1->Parameters->ParamByName("SERGB211")->Value=Edit5->Text;
ADOQuery1->Parameters->ParamByName("SERGB121")->Value=Edit6->Text;
ADOQuery1->Parameters->ParamByName("SERGB112")->Value=Edit7->Text;
ADOQuery1->ExecSQL();
}

terrenceman
一般會員


發表:7
回覆:7
積分:2
註冊:2007-01-05

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-04-26 18:58:26 IP:140.115.xxx.xxx 訂閱
stallion您好:

我剛試過了,在前面加上":"號,可是卻出現了"UPDATE陳述式語法發生錯誤"!
還是沒辦法正常執行! ><"
Stallion
版主


發表:52
回覆:1600
積分:1995
註冊:2004-09-15

發送簡訊給我
#4 引用回覆 回覆 發表時間:2007-04-26 20:04:31 IP:211.22.xxx.xxx 未訂閱
上一篇僅只討論動態變數的寫法。
你現在發生的錯誤應該跟SQL語法無關,極有可能的地方是你的TABLE裡面所定義的欄位型態,跟你現在所要賦予的值型態不合所造成的,請檢查一下你的資料型態部分是否吻合。
系統時間:2024-04-18 22:23:48
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!