我的插入代码
total:=form3.ADOQuery1.RecordCount+1; showmessage(inttostr(total));
form3.ADOQuery1.Close;
form3.ADOQuery1.SQL.Text:='insert into ['+getyuyan+'](ID,标题,内容) values(:total,"aaa","bbb")';
form3.ADOQuery1.ExecSQL;
我更新代码
with form3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('update '+getyuyan+' set 内容='''+Memo1.Text+''' where 标题='+form3.ComboBox1.Text+'');
ExecSQL;
end;
什么地方错了?
total:=form3.ADOQuery1.RecordCount+1; showmessage(inttostr(total));
form3.ADOQuery1.Close;
form3.ADOQuery1.SQL.Text:='insert into ['+getyuyan+'](ID,标题,内容) values(:total,"aaa","bbb")';
form3.ADOQuery1.ExecSQL;
我更新代码
with form3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('update '+getyuyan+' set 内容='''+Memo1.Text+''' where 标题='+form3.ComboBox1.Text+'');
ExecSQL;
end;
什么地方错了?
total:=form3.ADOQuery1.RecordCount+1; showmessage(inttostr(total));
form3.ADOQuery1.Close;
form3.adoquery1.sql.clear;//notice ,you must clear the sql before new sql.
form3.ADOQuery1.SQL.Text:='insert into ['+getyuyan+'](ID,标题,内容) values(:total,"aaa","bbb")';
form3.ADOQuery1.ExecSQL;
我更新代码
with form3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('update '+getyuyan+' set 内容='''+Memo1.Text+''' where 标题='+form3.ComboBox1.Text+'');
ExecSQL;
end;
什么地方错了?
参数赋值不是这样子的。
你可以改一下你的语名
form3.ADOQuery1.SQL.Text:='insert into ['+getyuyan+'](ID,标题,内容) values('''+total+''',"aaa","bbb")';
加引号的话最好是QuotedStr
total:=form3.ADOQuery1.RecordCount+1; showmessage(inttostr(total));
form3.ADOQuery1.Close;
form3.ADOQuery1.SQL.Text:='insert into ['+getyuyan+'](ID,标题,内容) values('+#39+inttostr(total)+#39+','+#39+'aaa'+#39+','+#39+'bbb'+#39+')';
form3.ADOQuery1.ExecSQL;
更新代码
with form3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('update '+getyuyan+' set 内容='+#39+Memo1.Text+#39+' where 标题='+#39+form3.ComboBox1.Text+#39);
ExecSQL;
end;
我在http://www.pediy.com/tutorial/appen-a/append-A.htm查到#39是个',直接写为什么不可以呢?
另外:我的数据库里total是int,为什么整形变量要inttostr(total)才能成功?
//*******************************************************************************