WITH QUERY DO 
  BEGIN
    CLOSE;
    SQL.CLEAR;
    SQL.ADD('UPDATE TABLE SET A=:A')
    PARAMETERS[0]:='DLKFJDS'
    EXECUTE;
  END;

解决方案 »

  1.   

    query.close;
    query.sql.clear;
    query.sql.add('update table set xxx=xxxx where xxx');
    query.execsql
      

  2.   

    qryMain.Close ;
            qryMain.SQL.Clear ;
            qryMain.SQL.Add('UPDATE userCourse');
            qryMain.SQL.Add('SET coursewareNumber = :pCWN');
            qryMain.SQL.Add('WHERE userName = :pUserID');
            qryMain.SQL.Add('AND subject = :pSubject');
            qryMain.Parameters.ParamValues['pCWN'] := NextPos;
            qryMain.Parameters.ParamValues['pUserID'] := vUserID;
            qryMain.Parameters.ParamValues['pSubject'] := vSubject;
            if qryMain.ExecSQL > 0 then
            begin
              vResult := 0; //成功更新客户进程记录
            end
            else
            begin
              vResult := 4; // 客户进程记录更新失败
            end;
          end;
          qryMain.Close ;
      

  3.   

    update table1 set fld1 = '...' where fld0 = ...
      

  4.   

    with query do
    begin
      close;
      sql.clear;
      sql.add('update table set name=:@name');
      parambyname('@name').value:='bbs';
      execsql;
    end;
      

  5.   

    update table1 set fld1 = '...' where fld0 = ...
      

  6.   

    语句我当然知道了,我是说用控件怎么实现,用adodataset可以实现吗
      

  7.   

    你不是问怎么用sql语句实现吗?
      

  8.   

    在adodataset的commandtext写sql语句就可以了。commandtype是cmdtext
      

  9.   

    我是问在delphi中怎么实现,你不知道,delphi中全是控件呀
      

  10.   

    Delphi6,控件面板BDE(Dehphi5在Data Access里)中有一个query控件,其中有个里面有个SQL属性,是写SQL语言的地方,然后照楼上的兄弟所写就好了!
      

  11.   

    with query do
    begin
      close;
      sql.clear;
     // sql.add('update table set name=:@name');
     // parambyname('@name').value:='bbs';有问题;
      execsql;
    end;
    改为
    with query do
    begin
      close;
      sql.clear;
      sql.add('update table set name='+Value);
      execsql;
    end;
    其中Value一定要设成符合SQL语法的字符串
      

  12.   

    有没有人会用adodataset的commandtext属性实现呀?query我也用了,报的错误跟我用adodataset的错误一样
      

  13.   

    你在commandtext里写了什么?报了什么错误?
      

  14.   

    update table set diduan=2 where condition
    记录不能更新
      

  15.   

    try
       with DataModule1 do
       begin
       if not Tablevoduser.Active
       then Tablevoduser.Active := True;
       Tablevoduser.Append;
       Queryuser.Close;
       Queryuser.SQL.Clear;
       Queryuser.SQL.Add('INSERT INTO  dbo.TABLEvoduser' );
       Queryuser.SQL.Add('(userid,userpassword,username,usermoney)');
       Queryuser.SQL.Add('VALUES(:Userid,:Password,:username,:usermoney)');
       Queryuser.Params[0].AsString:= userid;
       Queryuser.Params[1].AsString:= Password;
       Queryuser.Params[2].AsString:= username;
       Queryuser.Params[3].AsFloat:= strtofloat(usermoney);
       Queryuser.Prepare;
       Queryuser.ExecSQL;
        end;
      except
        ShowMessage('数据库添加用户错误');
      end;
      

  16.   

    try
       with DataModule1 do
       begin
       if not Tablevoduser.Active
       then Tablevoduser.Active := True;
       Tablevoduser.Append;
       Queryuser.Close;
       Queryuser.SQL.Clear;
       Queryuser.SQL.Add('INSERT INTO  dbo.TABLEvoduser' );
       Queryuser.SQL.Add('(userid,userpassword,username,usermoney)');
       Queryuser.SQL.Add('VALUES(:Userid,:Password,:username,:usermoney)');
       Queryuser.Params[0].AsString:= userid;
       Queryuser.Params[1].AsString:= Password;
       Queryuser.Params[2].AsString:= username;
       Queryuser.Params[3].AsFloat:= strtofloat(usermoney);
       Queryuser.Prepare;
       Queryuser.ExecSQL;
        end;
      except
        ShowMessage('数据库添加用户错误');
      end;
      

  17.   

    我用的是adodataset的conmmandtext属性
      

  18.   

    用adodataset或者是adoquery是不是不能修改记录呀,为什么他告诉我不能返回一个值呢
      

  19.   

    query怎么跟数据库连接呀,中间用什么控件呀
      

  20.   

    可以用ConnectionString连接库,也可以通过AdoConnection连接,当然你的AdoConnection必须连接好了。
      

  21.   

    问题应该是query的connectionstring没有设置好吧。用的是什么数据库?
      

  22.   

    我用的是access数据库,好象我用query时更本不行呀,你可不可以试完了再告诉我呀
      

  23.   

    是不是你用了Open?如果你是update或inserter等等不能返回记录的sql语句的话就要用ExecSQL来执行语句,否则会提示不能返回一个值的。