现在的位置: 首页 > 综合 > 正文

Delphi中TADOQuery执行存储过程

2013年08月08日 ⁄ 综合 ⁄ 共 741字 ⁄ 字号 评论关闭

 TADOQuery是Delphi中的ado控件,都用来执行Sql语句,当然用来执行存储过程也不在话下。

ADOQuery: TADOQuery;
with ADOQuery do
      begin
        Close;
       SQL.Text:='exec usp_getValue :refout out';
       try
         ExecSQL;
         count := parameters.ParamByName('refout').Value;
         if  (count>0)   then
          begin
           result :=True;
          end
          else
          begin
           result :=False;
          end;
       except
         on E: Exception do
         begin
           result := FALSE;
         end;
       end;
      end;

在这个过程中我们就使用一个存储过程参数,并且是输出类的。以下是3个参数,一个输入,2个输出的。

SQL.Text:='exec getoutcalltel :clientId, :refId out, :refTel out';

上面这句话是正确的,但是我在使用的过程中发现怎么个问题。

SQL.Text:='exec getoutcalltel :clientId,:refId out,:refTel out';

这样就会出错,就是去掉了中间了一个空格就会出现 存储过程传递常量时不能使用 OUTPUT 选项 这样一个错误。Delphi接触不久,不知道有没有错。呵呵

抱歉!评论已关闭.