在线等待,C++ Builder的语法错误
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ADOQuery1->SQL->Text="Select gnum,gname,gcount,manufacturer from dbo.goods where gnum = '" + Edit1->Text + "'" ;
ADOQuery1->ExecSQL();
ADOQuery1->Active=true;
String strSQL="";
strSQL="Update dbo.goods set gcount = gcount + StrToInt(Edit2->Text)";
ADOQuery1->SQL->Text=strSQL;
ADOQuery1->ExecSQL();
}
[解决办法]
strSQL="Update dbo.goods set gcount = gcount + StrToInt(Edit2->Text)";
改成:
strSQL="Update dbo.goods set gcount = gcount + " + IntToStr(Edit2->Text.ToInt());
[解决办法]
如果gnum字段是数字,就这样写:
strSQL="Update dbo.goods set gcount = gcount + " + Edit2->Text + " where gnum = " + Edit1->Text;
如果gnum字段是字符型,就这样写:
strSQL="Update dbo.goods set gcount = gcount + " + Edit2->Text + " where gnum = '" + Edit1->Text + "'";