我有一段用BUTTON删除DBgrid里面的数据并提交的代码,但是老是有错误,代码如下:begin
with dbgrid1 do
begin
if query1.Active=true then
query1.close;
query1.SQL.Clear;
query1.sql.Add('delete from house');
query1.SQL.Add('where id=?? ');
query1.ExecSQL;
问号表示不知道怎么写
谁能帮我看看啊
主要是我写不来删除当前指针所指向的数据。

解决方案 »

  1.   

    query1.SQL.Add('where id=:A ');
    query1.params.parambyname('A').asstring:=你的内容;或者就直接写了...
    query1.SQL.Add('where id=abc ');也要看你id的类型,要不是字符,还要转化
      

  2.   


    var
    str:string;beginwith dbgrid1 do
    begin
    if query1.Active=true then
    query1.close;
    query1.SQL.Clear;
    query1.sql.Add('delete from house');
    query1.SQL.Add('where id=?? ');
    str:=query1.SQL.text;
    query1.ExecSQL;
    答案好象你就知道了   house 和 where 之间没有  空格
      

  3.   

    晕,你直接删除怎么了?
    DBGrid1.DataSource.DataSet.Delete;