标准表达式中数据类型不匹配
AnsiString cEndTime = FormatDateTime("yyyy-mm-dd",Now()); Form1->ArrayType="TerminalType,Building,Unit,Storey,Room,TNum"; DataModule35->qry3->Close(); DataModule35->qry3->SQL->Clear(); DataModule35->qry3->SQL->Add("Select " + Form1->CdtCol + " from cdtinfo"); DataModule35->qry3->SQL->Add(" where ComputerNo = :ComputerNo and (TerminalType = 3 or TerminalType = 4)"); DataModule35->qry3->SQL->Add(" and Address in (select Author from CardAuthor where CardNo in(Select CardNo from Card where EndTime <= :cEndTime))"); DataModule35->qry3->Parameters->ParamByName("cEndTime")->Value = cEndTime;
DataModule35->qry3->Parameters->ParamByName("cEndTime")->Value = StrToDateTime( cEndTime);
[解决办法]
SQL语句中直接用字符串试试:
AnsiString cEndTime = FormatDateTime("yyyy-mm-dd", Now());String strSQL = String().sprintf("Select %s from cdtinfo" " where ComputerNo = :ComputerNo and (TerminalType = 3 or TerminalType = 4" " and Address in (select Author from CardAuthor where CardNo in " "(Select CardNo from Card where EndTime <= '%s')))", Form1->CdtCol, cEndTime);DataModule35->qry3->Close();DataModule35->qry3->SQL->Text = strSQL;...