buggy dbExpress driver for MSSQL(50分)

  • 主题发起人 主题发起人 chillkwanjane
  • 开始时间 开始时间
C

chillkwanjane

Unregistered / Unconfirmed
GUEST, unregistred user!
我这样用dbExpress调用我的MsSql2000的存储过程(Delphi7,已经打了update1的补丁
):

SQLConnection1.ConnectionName = 'MSSQL';
SQLDataSet1.SQLConnection := SQLConnection1;
SQLDataSet1.SchemaName = 'dbo';
...
SQLDataSet1.SQLConnection = SQLConnection1;
SQLDataSet1.CommandType := ctStoredProc;
SQLDataSet1.CommandText := 'p1';
SQLDataSet1.ExecSQL;
Result := SQLDataSet1.ParamByName('@p1').AsInteger;
数据库里原本有存储过程
create table t1(
id integer not null primary key,
name varchar(10)
)
go
insert into t1 values ( 1, NULL )
go
create procedure p
@p integer output
as
begin
select @p = id from t1 where id = 1
if (not exists(select * from t1 where id = 2))
insert into t1 values ( 2, '10' )
end
go
create procedure p1
@p1 integer output
as
begin
execute p @p1 output
end
go

这个存储过程在isqlw, dbGo(ADOExpress)中能够正确返回1,但是dbExpress却返回0
但是下面的能够正确返回1
alter procedure p
@p integer output
as
begin
select @p = id from t1 where id = 1
end
go
SQLDataSet1.SQLConnection = SQLConnection1;
SQLDataSet1.CommandType := ctStoredProc;
SQLDataSet1.CommandText := 'p';
//p, not p1
SQLDataSet1.ExecSQL;
Result := SQLDataSet1.ParamByName('@p').AsInteger;

下面的存储过程p2也不能被dbExpress正确返回参数:
设有:
create procedure p2
@p2 integer output
as
begin
declare cursor_id cursor for
select id from t1 where id = 1
open cursor_id
fetch next from cursor_id into @p2
update t1 set
name = 'abc'
where current of cursor_id
close cursor_id
deallocate cursor_id
end
go
调用时,
SQLDataSet1.SQLConnection = SQLConnection1;
SQLDataSet1.CommandType := ctStoredProc;
SQLDataSet1.CommandText := 'p2';
SQLDataSet1.ExecSQL;
Result := SQLDataSet1.ParamByName('@p2').AsInteger;
这个存储过程同样返回0,而dbGo正确返回了1

为什么呢???是bug吗?
 
补丁在哪可下?
或请发ninglng@163.com
万分感谢!!!
 
那可以到
ftp://ftpd.borland.com/devsupport/delphi/d7/mssql/mssqlupdate.zip
或者
http://www.borland.co.za/ftp/pub/delphi/devsupport/updates/delphi7/update1/
 
看一看这一段:如果没有启发再问我。解决了通知我一声:我测试过没有问题。
SchemaName:='dbo';
StoredProcName:='UpdateDataDay';Params.Clear;
Params.CreateParam(ftInteger, 'RETURN_VALUE', ptOutput );
Params.CreateParam(ftString, '@CurDAY', ptInput);
Params.CreateParam(ftString, '@PreDAY', ptInput);
Params.CreateParam(ftInteger, '@ErrorCode', ptOutput );
Params.ParamByName('@CurDAY').AsString:=DateToStr(iRq);
Params.ParamByName('@PreDAY').AsString:=DateToStr(aPreRq);
Params.ParamByName('@ErrorCode').AsInteger:=ErrorCode;
Params.ParamByName('RETURN_VALUE').AsInteger:=ErrorCode;
ExecProc;
 

Similar threads

I
回复
0
查看
734
import
I
D
回复
0
查看
828
DelphiTeacher的专栏
D
I
回复
0
查看
875
import
I
D
回复
0
查看
844
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部