各位好心人,帮我!如何在Delphi中表述下列SQL语句INSERT INTO MyTable (PriKey, Description)
       VALUES (123, 'A description of part 123.')

解决方案 »

  1.   


    with adoquery1 do
    begin
      Close;
      SQL.Text := 'INSERT INTO MyTable (PriKey, Description) VALUES (123, ''A description of part 123.'')';
      ExecSQL;
    end;
      

  2.   

    adoquery1.close;
    adoquery1.sql.text := ' INSERT INTO MyTable (PriKey, Description) '+
                          ' VALUES (123, '+QuotedStr('A description of part 123.') +')';
    adoquery1.execSql;
      

  3.   

    或者用参数with adoquery1 do
    begin
      Close;
      SQL.Text := 'INSERT INTO MyTable (PriKey, Description) VALUES (:PK, :Desc)';
      Parameters.ParamByName('PK').Value := 123;
      Parameters.ParamByName('Desc').Value := 'A description of part 123.';
      ExecSQL;
    end;
      

  4.   

    with ADOQuery1 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('INSERT INTO MyTable(PriKey, Description) VALUES(123, ''A description of part 123.'') ');
        ExecSQL;
      end;
      

  5.   

    我把问题提得具体点:SQL语句: UPDATE qzqxt_sjdx SET A='B'  WHERE Ldate ='C';
    其中A,B,C分别为程序中的变量如何在Delphi中表达???
      

  6.   

    var
      A,B,C :string;
    begin
      with ADOQuery1 do
      begin
        Close;
        sql.Clear;
        SQL.Add(update 表 set ''A''='''+B+''' where LDate='''+C+''');
        ExecSQL;
      end;
      

  7.   

    完正點的
    with qry do//注:qry是你的dataquery 
    beign
    close;
    sql.clear;
    sql.add ( ' update qzqxt_sjdx set a=:bb where ldate=:cc ' );
    parambyname('bb').asstring:='b';
    parambyname('cc').asstring:='c';
    execqsl;
    end;
    欢迎指正 谢谢!