我要在delphi程序中调用ado控件,并要使用这些控件在Sql Server上创建一个带两个输入参数的存储过程,并执行,请问我该怎么做

解决方案 »

  1.   

    把SQL语句写到ADOQUERY里就可以了呀,
    但是不能有GO ,
    当然可能要用多次。
      

  2.   

    同意,例子:
    with adoquery do
    begin
    if active then close;
    sql.clear;
    sql.add('
    CREATE PROC ProcTest1
      @inttest smallint
      ,@strtest char(4) output
    AS
      INSERT INTO TEST_User.TRANS_TEST
      VALUES(@inttest,@strtest)
      SELECT @strtest,* FROM TEST_User.TRANS_TEST');
    open;
      

  3.   

    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add('create procedure youproc');
    adoquery1.sql.add('@p1 int,@p2 int');
    adoquery1.sql.add('as .......'); //其它的语句
    adoquery1.execsql;adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add('exec youproc :p1,:p2');
    adoquery1.Parameters.ParamValues['p1']:=3;
    adoquery1.Parameters.ParamValues['p2']:=3;
    adoquery1.execsql;