 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jacob Pedersen Guest
|
Posted: Fri Nov 21, 2003 10:50 am Post subject: Problem with params with TSQLStoredProc |
|
|
Example:
function GetNextNumber(const SQLConnection : TSQLConnection; TheTable:
string; Increase: Integer = 1): Integer; overload;
begin
if not Assigned(MySP) then
begin
MySP := TSQLStoredProc.Create(nil);
MySP.SQLConnection := SQLConnection; // needed for dbExpress
MySP.StoredProcName := 'GetNextNumber';
MySP.SchemaName := 'dbo';
MySP.Params.CreateParam(ftString, '@TableName', ptInput);
MySP.Params.CreateParam(ftInteger, '@Increase', ptInput);
MySP.Params.CreateParam(ftInteger, '@Identity', ptOutput);
end;
MySP.SQLConnection := SQLConnection;
MySP.ParamByName('@TableName').AsString := 'testtable';
MySP.ParamByName('@Increase').AsInteger := 1;
MySP.ExecProc;
Result := MySP.ParamByName('@Identity').AsInteger;
end;
From SQL Profiler:
declare @P1 int
set @P1=2
declare @P2 int
set @P2=NULL
exec sp_prepexecrpc @P1 output, N'"dbo"."GetNextNumber"', @TableName = '',
@Increase = 0
select @P1
As you can see @TableName is set to what looks like a square and @Increase
is 0. @Identity is not there at all.
If you add a dummy param after Identity, I get the Identity param (and then
not the dummy param), but still the params are not used by dbExpress.
I'm using latest dbExpress driver from august.
Same code with BDE works fine!
Example:
if not Assigned(MySP) then
begin
MySP := TStoredProc.Create(nil);
MySP.DatabaseName := MyDB.DatabaseName;
MySP.StoredProcName := 'GetNextNumber';
MySP.Params.CreateParam(ftString, '@TableName', ptInput);
MySP.Params.CreateParam(ftInteger, '@Increase', ptInput);
MySP.Params.CreateParam(ftInteger, '@Identity', ptOutput);
end;
MySP.DatabaseName := TheDatabase;
MySP.ParamByName('@TableName').AsString := Trim(TheTable);
MySP.ParamByName('@Increase').AsInteger := Increase;
MySP.ExecProc;
Result := MySP.ParamByName('@Identity').AsInteger
This clearly is a huge dbExpress bug or?!
--
Jacob Pedersen
AK Techotel
[email]J.PedersenGOAWAY (AT) noXspaMtechotel (DOT) dk[/email]
(Remove GOAWAY and noXspaM when replying!)
|
|
| Back to top |
|
 |
Jacob Pedersen Guest
|
Posted: Tue Nov 25, 2003 2:57 pm Post subject: Re: Problem with params with TSQLStoredProc |
|
|
I downloaded the CoreLabs dbExpress driver for MSSQL to see if that would
fix the problem. Keeping in mind that it is a trial version... Does not
even get as far as Borlands driver. I get List Index out of bounds (4).
Looking at the stack, the problem seems to be related to params. *sight*
You can say alot about BDE but atleast it could call stored procs without
problems...
Is it really true noone can help? Do I have to go the ADO way :(
--
Jacob Pedersen
AK Techotel
[email]J.PedersenGOAWAY (AT) noXspaMtechotel (DOT) dk[/email]
(Remove GOAWAY and noXspaM when replying!)
|
|
| Back to top |
|
 |
Ricardo Guest
|
Posted: Tue Nov 25, 2003 9:49 pm Post subject: Re: Problem with params with TSQLStoredProc |
|
|
Did you see the trial limitations?
The CoreLab driver only show 6 Fields, for example.
"Jacob Pedersen" <J.Pedersen (AT) techotel (DOT) dk> escreveu na mensagem
news:Xns943EACBA098D3jpedersentechotel (AT) 207 (DOT) 105.83.66...
| Quote: | I downloaded the CoreLabs dbExpress driver for MSSQL to see if that would
fix the problem. Keeping in mind that it is a trial version... Does not
even get as far as Borlands driver. I get List Index out of bounds (4).
Looking at the stack, the problem seems to be related to params. *sight*
You can say alot about BDE but atleast it could call stored procs without
problems...
Is it really true noone can help? Do I have to go the ADO way :(
--
Jacob Pedersen
AK Techotel
[email]J.PedersenGOAWAY (AT) noXspaMtechotel (DOT) dk[/email]
(Remove GOAWAY and noXspaM when replying!)
|
|
|
| Back to top |
|
 |
Jacob Pedersen Guest
|
Posted: Wed Nov 26, 2003 8:38 am Post subject: Re: Problem with params with TSQLStoredProc |
|
|
"Ricardo" <no (AT) no (DOT) com> wrote in news:3fc3ce33$1 (AT) newsgroups (DOT) borland.com:
| Quote: | Did you see the trial limitations?
The CoreLab driver only show 6 Fields, for example.
|
Yes I know but this has nothing to do with calling a simple
stored proc like in my example... Normal TSQLQuery works
fine with CoreLabs except it seemed alot slower. Might just be
me...
--
Jacob Pedersen
AK Techotel
[email]J.PedersenGOAWAY (AT) noXspaMtechotel (DOT) dk[/email]
(Remove GOAWAY and noXspaM when replying!)
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|