为什么用TDataBase建交临时SQL连接,连接成功后,使用TStoredProcr控件执行存储过程要报General SQL error.错误喃,而用TQu

  • 主题发起人 主题发起人 Pinaster01
  • 开始时间 开始时间
P

Pinaster01

Unregistered / Unconfirmed
GUEST, unregistred user!
为什么用TDataBase建交临时SQL连接,连接成功后,使用TStoredProcr控件执行存储过程要报General SQL error.错误喃,而用TQuery不会呢? ( 积分: 100 )<br />我放一TDataBase控件,双击设DataBaseName为abc,设DriverName为MSSQL,然后按defaults后,把参数改为如下
DATABASE NAME=drink
SERVER NAME=ciserver
USER NAME=sa
OPEN MODE=READ/WRITE
SCHEMA CACHE SIZE=8
BLOB EDIT LOGGING=
LANGDRIVER=
SQLQRYMODE=
SQLPASSTHRU MODE=SHARED AUTOCOMMIT
DATE MODE=0
SCHEMA CACHE TIME=-1
MAX QUERY TIME=300
MAX ROWS=-1
BATCH COUNT=200
ENABLE SCHEMA CACHE=FALSE
SCHEMA CACHE DIR=
HOST NAME=
APPLICATION NAME=
NATIONAL LANG NAME=
ENABLE BCD=FALSE
TDS PACKET SIZE=4096
BLOBS TO CACHE=64
BLOB SIZE=32
PASSWORD=

放如一个TStoredProc控件,DataBaseName设为TDataBase的DataBaseName,然后增加相应的代码
procedure TForm2.adfdf;
var
RETURN_VALUE_Param : TParam;
Call_Param : TParam;
Flag_Param : TParam;
begin
RETURN_VALUE_Param := nil;
Call_Param := nil;
Flag_Param := nil;
try
With StoredProc1 do
begin
StoredProcName := 'SetSta';

RETURN_VALUE_Param := TParam.Create(Params,ptResult);
RETURN_VALUE_Param.Name := 'RETURN_VALUE';
RETURN_VALUE_Param.DataType := ftInteger;
Call_Param := TParam.Create(Params,ptInput);
Call_Param.Name := 'Callfh';
Call_Param.DataType := ftString;
Call_Param.Value := '101';
Flag_Param := TParam.Create(Params, ptInput);
Flag_Param.Name := 'SetFlag';
Flag_Param.DataType := ftInteger;
Flag_Param.Value := 1;

Prepare;
ExecProc;

Close;
end;
RETURN_VALUE_Param.Free;
Call_Param.Free;
Flag_Param.Free;
except
if RETURN_VALUE_Param <> nil then
begin
RETURN_VALUE_Param.Free;
end;
if Call_Param <> nil then
begin
Call_Param.Free;
end;
if Flag_Param <> nil then
begin
Flag_Param.Free;
end;
end;
end;

再程序起动过程中打开TDataBase,程序启动后,运行上面的过程就报错,但如果用TQuery控件设SQL为
exec gb_SetClientSta ''101'',1 就没问题,请高手帮忙解答一下为什么呢?
 
我放一TDataBase控件,双击设DataBaseName为abc,设DriverName为MSSQL,然后按defaults后,把参数改为如下
DATABASE NAME=drink
SERVER NAME=ciserver
USER NAME=sa
OPEN MODE=READ/WRITE
SCHEMA CACHE SIZE=8
BLOB EDIT LOGGING=
LANGDRIVER=
SQLQRYMODE=
SQLPASSTHRU MODE=SHARED AUTOCOMMIT
DATE MODE=0
SCHEMA CACHE TIME=-1
MAX QUERY TIME=300
MAX ROWS=-1
BATCH COUNT=200
ENABLE SCHEMA CACHE=FALSE
SCHEMA CACHE DIR=
HOST NAME=
APPLICATION NAME=
NATIONAL LANG NAME=
ENABLE BCD=FALSE
TDS PACKET SIZE=4096
BLOBS TO CACHE=64
BLOB SIZE=32
PASSWORD=

放如一个TStoredProc控件,DataBaseName设为TDataBase的DataBaseName,然后增加相应的代码
procedure TForm2.adfdf;
var
RETURN_VALUE_Param : TParam;
Call_Param : TParam;
Flag_Param : TParam;
begin
RETURN_VALUE_Param := nil;
Call_Param := nil;
Flag_Param := nil;
try
With StoredProc1 do
begin
StoredProcName := 'SetSta';

RETURN_VALUE_Param := TParam.Create(Params,ptResult);
RETURN_VALUE_Param.Name := 'RETURN_VALUE';
RETURN_VALUE_Param.DataType := ftInteger;
Call_Param := TParam.Create(Params,ptInput);
Call_Param.Name := 'Callfh';
Call_Param.DataType := ftString;
Call_Param.Value := '101';
Flag_Param := TParam.Create(Params, ptInput);
Flag_Param.Name := 'SetFlag';
Flag_Param.DataType := ftInteger;
Flag_Param.Value := 1;

Prepare;
ExecProc;

Close;
end;
RETURN_VALUE_Param.Free;
Call_Param.Free;
Flag_Param.Free;
except
if RETURN_VALUE_Param <> nil then
begin
RETURN_VALUE_Param.Free;
end;
if Call_Param <> nil then
begin
Call_Param.Free;
end;
if Flag_Param <> nil then
begin
Flag_Param.Free;
end;
end;
end;

再程序起动过程中打开TDataBase,程序启动后,运行上面的过程就报错,但如果用TQuery控件设SQL为
exec gb_SetClientSta ''101'',1 就没问题,请高手帮忙解答一下为什么呢?
 
后退
顶部