各位大虾:
小的,有条Update语句太长了,不知道如何分割开:
CmdStr:='Update zotheruserlist';
CmdStr:=CmdStr+Format(' Set zusertype=%d,...where zotheruserid=%d',[TypeID,...StrToInt(CarderNo.Text)]);
SQL.Add(CmdStr);
ExecSQL;
请教:怎样把第二条CmdStr:=CmdStr+Format...分成两至三段。。
能不能这么分:
CmdStr:='Update zotheruserlist';
CmdStr:=CmdStr+Format(' Set zusertype=%d,...');
CmdStr:=CmdStr+Format(' Where zotheruserid=%d',[TypeID,...StrToInt(CarderNo.Text)]);
SQL.Add(CmdStr);
ExecSQL;
请教!
我试了,还是不行,最主要的是[TypeID,...StrToInt(CarderNo.Text)]这一部分还有.用两个Format对吗??
请教!!!
各位大虾,小的很很急需解决的!!!
小的,有条Update语句太长了,不知道如何分割开:
CmdStr:='Update zotheruserlist';
CmdStr:=CmdStr+Format(' Set zusertype=%d,...where zotheruserid=%d',[TypeID,...StrToInt(CarderNo.Text)]);
SQL.Add(CmdStr);
ExecSQL;
请教:怎样把第二条CmdStr:=CmdStr+Format...分成两至三段。。
能不能这么分:
CmdStr:='Update zotheruserlist';
CmdStr:=CmdStr+Format(' Set zusertype=%d,...');
CmdStr:=CmdStr+Format(' Where zotheruserid=%d',[TypeID,...StrToInt(CarderNo.Text)]);
SQL.Add(CmdStr);
ExecSQL;
请教!
我试了,还是不行,最主要的是[TypeID,...StrToInt(CarderNo.Text)]这一部分还有.用两个Format对吗??
请教!!!
各位大虾,小的很很急需解决的!!!
CmdStr: string;
begin
CmdStr := '';
CmdStr := 'Update zotheruserlist' CmdStr := CmdStr + Format('Set zusertype=%d,zname=''%s'',zsex=''%s'',zbirthdate=''%s''',[TypeID,Trim(CarderName.Text),Trim(CarderSex.Text),DateToStr(BorthTime.Date)]); CmdStr := CmdStr+Format('znationality=%d,zbelongtocity=%d,zbelongtozone=%d,zidnumber=''%s'',ztempresid=''%s''', [NationID,ProvinceID,CountyID,Trim(CarderIdentity.Text),Trim(CarderStayed.Text)]); CmdStr := CmdStr + Format('ztempresexpire=''%s'',zpassportnum=''%s'',zemail=''%s'',zworkingcompany=''%s'',zphonenumber=''%s''',[DateToStr(StayedTime.Date),Trim(CarderPass.Text), Trim(CarderEmail.Text),Trim(CarderUnit.Text),Trim(CarderTel.Text)]); CmdStr := CmdStr + Format('zcellularnumber=''%s'',zaddress=''%s'',zpostcode=%d Where zotheruserid=%d',[Trim(CarderMobil.Text),Trim(CarderAddress.Text),IntToStr(Trim(CarderMail.Text)),Trim(CarderNo.Text)]); SQL.text := CmdStr;
end;
------------------------------------------------------------------------------------
建议看一下delphi帮助中format的用法.
不过在调试时,还是出错了》在倒数第二条:CmdStr := CmdStr + Format('zcellularnumber=''%s'',zaddress=''%.....
他的提示是:Project ConsumeApp.exe raise exception class EConvertError with message 'Format'%d'' invalid or incompatible with argument'.
什么问题,请教,能不能快回!小的急着赶工!!!
CmdStr := CmdStr + Format('zcellularnumber=''%s'',zaddress=''%s'',zpostcode=%d Where zotheruserid=%d',[Trim(CarderMobil.Text),Trim(CarderAddress.Text),IntToStr(Trim(CarderMail.Text)),IntToStr(Trim(CarderNo.Text))]);
CmdStr:='Update zotheruserlist'
CmdStr:=CmdStr+'set zusertype='+#39+TypeID+#39;
.
.
.
CmdStr:=CmdStr+'where zotheruserid='+#39+TypeID+#39;
.
.
.
SQL.Add(CmdStr);
%s代表string类型; %d代表Decimal类型;
CmdStr := CmdStr + Format('zcellularnumber=''%s'',zaddress=''%s'',zpostcode=''%s'' Where zotheruserid=''%s'',[Trim(CarderMobil.Text),Trim(CarderAddress.Text),IntToStr(Trim(CarderMail.Text)),Trim(CarderNo.Text)]);
把不匹配的%d改为%s试试,要加上''号;
不行阿!
还是出现那种错误。
我还专把%d的类型放在最后了,都不行。
怎么解决阿!
还有什么高招吗??
请教!