update 语句后面应该在哪里加where语句啊?急求

quietflower 2012-12-22 10:18:52
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ADOQuery1->SQL->Text="Select gnum,gname,gcount,manufacturer from dbo.goods " ;
ADOQuery1->ExecSQL();
ADOQuery1->Active=true;
String strSQL="";
//strSQL="Select gnum from dbo.goods where gnum= '" + Edit1->Text + "'" ;
strSQL="Update dbo.goods set gcount = gcount + " + IntToStr(Edit2->Text.ToInt());
//strSQL="Update dbo.goods set gcount = gcount+ "+IntToStr(Edit2->Text.ToInt()) where gnum= '"+Edit->Text+"'";
ADOQuery1->SQL->Text=strSQL;
ADOQuery1->ExecSQL();
ADOQuery1->SQL->Text="Select gnum,gname,gcount,manufacturer from dbo.goods" ;
ADOQuery1->Active=true;
}
...全文
278 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
quietflower 2012-12-22
  • 打赏
  • 举报
回复
很感谢你啊,问题解决了
dataxdata 2012-12-22
  • 打赏
  • 举报
回复
如果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 + "'";

1,178

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 数据库及相关技术
社区管理员
  • 数据库及相关技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧