在c++ builder+access数据库中怎么老是出现“标准表达式中数据类型不匹配”
我本来输入年月日时来查询某个小时内的所有数据,并画图的但老是出现提示:“标准表达式中数据类型不匹配”,我的具体程序如下:
void __fastcall TForm5::Button1Click(TObject *Sender)
{
AnsiString Year,Month,Day,Hour,Minute,Second;
Year=ComboBox1->Text;
Month=ComboBox2->Text;
Day=ComboBox3->Text;
Hour=ComboBox4->Text;
AnsiString str_arr = Year + "-" + Month + "-" + Day + " " + Hour + ":00:00";
AnsiString str_dep = Year + "-" + Month + "-" + Day + " " + IntToStr(StrToInt(Hour) + 1) + ":00:00";
AnsiString strSql = "select * from boxing where 时间 >= '"+ str_arr +"' and 时间 < '"+str_dep+"'";
Form1->ADOQuery5->Close();
Form1->ADOQuery5->SQL->Clear();
Form1->ADOQuery5->SQL->Add(strSql);
Form1->ADOQuery5->Open();
Form1->ADOQuery5->First();
DBGrid1-> Refresh();
TStringList *listA = new TStringList;
TStringList *listB = new TStringList;
TStringList *listC = new TStringList;
while(!Form1->ADOQuery5->Eof)
{
String d = Form1->ADOQuery5->FieldByName("时间")->AsDateTime;
String a = Form1->ADOQuery5->FieldByName("补偿回路报警A相电流值")->AsString;
String b = Form1->ADOQuery5->FieldByName("补偿回路报警B相电流值")->AsString;
String c = Form1->ADOQuery5->FieldByName("补偿回路报警C相电流值")->AsString;
listA->Add(a);
listB->Add(b);
listC->Add(c);
Form1->ADOQuery5->Next();
}
Form5->Image1->Width=680;
Form5->Image1->Height=300;
Form5->Image2->Width=720;
Form5->Image2->Height=300;
Form5->Image3->Width=600;
Form5->Image3->Height=300;
int x = 20;
//-----------------补偿回路报警A相电流值波形图---------------
this->Image2->Canvas->TextOut(0, Image2->Height -20 , "20");
this->Image2->Canvas->TextOut(0, Image2->Height -40, "40");
this->Image2->Canvas->TextOut(0, Image2->Height -60, "60");
this->Image2->Canvas->TextOut(0, Image2->Height -80, "80");
this->Image2->Canvas->TextOut(0, Image2->Height -100, "100");
this->Image2->Canvas->TextOut(0, Image2->Height -120, "120");
this->Image2->Canvas->TextOut(0, Image2->Height -140, "140");
this->Image2->Canvas->TextOut(0, Image2->Height -160, "160");
this->Image2->Canvas->TextOut(0, Image2->Height -180, "180");
this->Image2->Canvas->TextOut(0, Image2->Height-200 , "200");
this->Image2->Canvas->TextOut(0, Image2->Height-220 , "220");
this->Image2->Canvas->TextOut(0, Image2->Height-240 , "240");
this->Image2->Canvas->TextOut(0, Image2->Height-260 , "260");
this->Image2->Canvas->TextOut(0, Image2->Height-280 , "280");
this->Image2->Canvas->TextOut(0, Image2->Height-300 , "300");
this->Image2->Canvas->TextOut(40, 317, "40");
this->Image2->Canvas->TextOut(80, 317, "80");
this->Image2->Canvas->TextOut(120,317, "120");
this->Image2->Canvas->TextOut(160, 317, "160");
this->Image2->Canvas->TextOut(200, 317, "200");
this->Image2->Canvas->TextOut(240, 317, "240");
this->Image2->Canvas->TextOut(280, 317, "280");
this->Image2->Canvas->TextOut(320, 317, "320");
this->Image2->Canvas->TextOut(360, 317, "360");
this->Image2->Canvas->TextOut(400,317, "400");
this->Image2->Canvas->TextOut(440,317, "440");
this->Image2->Canvas->TextOut(480,317, "480");
this->Image2->Canvas->TextOut(520,317, "520");
this->Image2->Canvas->TextOut(560,317, "560");
this->Image2->Canvas->TextOut(600,317, "600");
this->Image2->Canvas->TextOut(640,317, "640");
this->Image2->Canvas->TextOut(680,317, "680");
this->Image2->Canvas->TextOut(720,317, "720");
this->Image2->Canvas->MoveTo(0, Image2->Height);
for(int i = 0; i < listA->Count; i++)
{
this->Image2->Canvas->LineTo(x, Image2->Height - StrToFloat(listA->Strings[i]) );
x += 0.2;
}
//-----------------补偿回路报警B相电流值波形图---------------
this->Image1->Canvas->TextOut(0, Image1->Height -20 , "20");
this->Image1->Canvas->TextOut(0, Image1->Height -40, "40");
this->Image1->Canvas->TextOut(0, Image1->Height -60, "60");
this->Image1->Canvas->TextOut(0, Image1->Height -80, "80");
this->Image1->Canvas->TextOut(0, Image1->Height -100, "100");
this->Image1->Canvas->TextOut(0, Image1->Height -120, "120");
this->Image1->Canvas->TextOut(0, Image1->Height -140, "140");
this->Image1->Canvas->TextOut(0, Image1->Height -160, "160");
this->Image1->Canvas->TextOut(0, Image1->Height -180, "180");
this->Image1->Canvas->TextOut(0, Image1->Height-200 , "200");
this->Image1->Canvas->TextOut(0, Image1->Height-220 , "220");
this->Image1->Canvas->TextOut(0, Image1->Height-240 , "240");
this->Image1->Canvas->TextOut(0, Image1->Height-260 , "260");
this->Image1->Canvas->TextOut(0, Image1->Height-280 , "280");
this->Image1->Canvas->TextOut(0, Image1->Height-300 , "300");
this->Image1->Canvas->TextOut(40, 340, "40");
this->Image1->Canvas->TextOut(80, 340, "80");
this->Image1->Canvas->TextOut(120,340, "120");
this->Image1->Canvas->TextOut(160, 340, "160");
this->Image1->Canvas->TextOut(200, 340, "200");
this->Image1->Canvas->TextOut(240, 340, "240");
this->Image1->Canvas->TextOut(280,340, "280");
this->Image1->Canvas->TextOut(320, 340, "320");
this->Image1->Canvas->TextOut(360, 340, "360");
this->Image1->Canvas->TextOut(400,340, "400");
this->Image1->Canvas->TextOut(440,340, "440");
this->Image1->Canvas->TextOut(480,340, "480");
this->Image1->Canvas->TextOut(520,340, "520");
this->Image1->Canvas->TextOut(560,340, "560");
this->Image1->Canvas->TextOut(600,340, "600");
this->Image1->Canvas->TextOut(640,340, "640");
this->Image1->Canvas->TextOut(680,340, "680");
this->Image1->Canvas->MoveTo(0, Image1->Height);
x = 20;
for(int j = 0; j< listB->Count; j++)
{
this->Image1->Canvas->LineTo(x, Image1->Height - StrToFloat(listB->Strings[j]));
x += 0.2;
}
//-----------------补偿回路报警C相电流值波形图---------------
this->Image3->Canvas->TextOut(0, Image3->Height -20 , "20");
this->Image3->Canvas->TextOut(0, Image3->Height -40, "40");
this->Image3->Canvas->TextOut(0, Image3->Height -60, "60");
this->Image3->Canvas->TextOut(0, Image3->Height -80, "80");
this->Image3->Canvas->TextOut(0, Image3->Height -100, "100");
this->Image3->Canvas->TextOut(0, Image3->Height -120, "120");
this->Image3->Canvas->TextOut(0, Image3->Height -140, "140");
this->Image3->Canvas->TextOut(0, Image3->Height -160, "160");
this->Image3->Canvas->TextOut(0, Image3->Height -180, "180");
this->Image3->Canvas->TextOut(0, Image3->Height-200 , "200");
this->Image3->Canvas->TextOut(0, Image3->Height-220 , "220");
this->Image3->Canvas->TextOut(0, Image3->Height-240 , "240");
this->Image3->Canvas->TextOut(0, Image3->Height-260 , "260");
this->Image3->Canvas->TextOut(0, Image3->Height-280 , "280");
this->Image3->Canvas->TextOut(0, Image3->Height-300 , "300");
this->Image3->Canvas->TextOut(40, 310, "40");
this->Image3->Canvas->TextOut(80, 310, "80");
this->Image3->Canvas->TextOut(120,310, "120");
this->Image3->Canvas->TextOut(160, 310, "160");
this->Image3->Canvas->TextOut(200, 310, "200");
this->Image3->Canvas->TextOut(240, 310, "240");
this->Image3->Canvas->TextOut(280,310, "280");
this->Image3->Canvas->TextOut(320, 310, "320");
this->Image3->Canvas->TextOut(360, 310, "360");
this->Image3->Canvas->TextOut(400,310, "400");
this->Image3->Canvas->TextOut(440,310, "440");
this->Image3->Canvas->TextOut(480,310, "480");
this->Image3->Canvas->TextOut(520,310, "520");
this->Image3->Canvas->TextOut(560,310, "560");
this->Image3->Canvas->TextOut(600,310, "600");
this->Image3->Canvas->TextOut(640,310, "640");
this->Image3->Canvas->TextOut(680,310, "680");
x = 20;
this->Image3->Canvas->MoveTo(0, Image3->Height);
for(int h= 0; h< listB->Count; h++)
{
this->Image3->Canvas->LineTo(x, Image3->Height - StrToFloat(listC->Strings[h]) );
x += 0.2;
}
}
各位高手们帮帮小弟的忙吧,我找了很久没找到错误的地方,谢谢!!
[最优解释]
DataTable1=FormatDateTime("'HSpeed_'YYYYMM",StartDate->Date);
StartDateTime=FormatDateTime("YYYY'-'MM'-'DD' '",StartDate->Date);
StartDateTime+=StartTime->Text;
EndDateTime=FormatDateTime("YYYY'-'MM'-'DD' '",EndDate->Date);
EndDateTime+=EndTime->Text;
/**/
SqlStr=" Select * from ";
SqlStr+=DataTable1;
SqlStr+=" Where VEH_DATETIME BETWEEN '";
SqlStr+=StartDateTime;
SqlStr+="' AND '";
SqlStr+=EndDateTime+"' ";
AnsiString strSql = String().sprintf(
"select * from [boxing] where [时间] "
"between #%s-%s-%s %s:00:00# and #%s-%s-%s %s:00:00#",
Year, Month, Day, Hour,
Year, Month, Day, IntToStr(StrToInt(Hour) + 1));