各位大侠:
小弟最近由于一个项目由.NET转到Delphi了,有个数据库删除操作一直没搞定,希望大家帮我看看,谢谢。是通过在ListBox中选取一位人的名字,在数据库中进行删除。
代码是这样写的:
str_name:=ListBox1.Items[ListBox1.ItemIndex];
Form1.ADOQuery1.Close;
Form1.ADOQuery1.SQL.Clear;
str_sql:='delete from Teacher where Name=' + '''' + str_name + '''';
Form1.ADOQuery1.SQL.Add(str_sql);
Form1.ADOQuery1.Active:=true;
Form1.ADOQuery1.ExecSQL;
老是报错,说是不能返回多条数据集,不知道什么原因。
小弟最近由于一个项目由.NET转到Delphi了,有个数据库删除操作一直没搞定,希望大家帮我看看,谢谢。是通过在ListBox中选取一位人的名字,在数据库中进行删除。
代码是这样写的:
str_name:=ListBox1.Items[ListBox1.ItemIndex];
Form1.ADOQuery1.Close;
Form1.ADOQuery1.SQL.Clear;
str_sql:='delete from Teacher where Name=' + '''' + str_name + '''';
Form1.ADOQuery1.SQL.Add(str_sql);
Form1.ADOQuery1.Active:=true;
Form1.ADOQuery1.ExecSQL;
老是报错,说是不能返回多条数据集,不知道什么原因。
begin
str_name:=listbox1.Items[listbox1.Itemindex];
end;procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.ADOQuery1.Close;
Form1.ADOQuery1.SQL.Clear;
str_sql:='delete from Teacher where Name='+Quotedstr(str_name);
Form1.ADOQuery1.SQL.Add(str_sql);
Form1.ADOQuery1.ExecSQL;
end;