Discussion:
Problem with StoredProc
(too old to reply)
Eduardo Jauch
2008-03-26 17:51:17 UTC
Permalink
Hi

I create this TSQLDataSet:

FCarsDocLDS := TSQLDataSet.Create(nil);
FCarsDocLDS.SQLConnection := FCarsConnection;
FCarsDocLDS.CommandType := ctStoredProc;
FCarsDocLDS.CommandText := 'msDocL';
FCarsDocLDS.Params.CreateParam(ftInteger, '@idDocAM', ptInputOutput);

Then, I use it like this:

with FCarsDocLDS do
begin
if Active then
Close;

ParamByName('@idDocAM').AsInteger := FCarsDocAMDS.FieldByName('idDocAM').AsInteger;

Open;
First;
end;

My problem is: All the involved DBexpress components are created on runtime, But when I try to execute the Open (Because the Sp returns a cursor) my Thread Exits.
The Open Start an Exception that I can't catch. My E (from E : Exception) is always nil.

So, I don't know what is happening...

If I use the value on FCarsDocAMDS.FieldByName('idDocAM').AsInteger; to execute the StoredProc on the SQL Query Analyser, it returns the data existent on the database.

I try to use the SchemaName := 'dbo', but it doesn't work...
On the contrary, start an exception saying that the @idDocAM parameter doesn't exist.

It's not a problem of connection, because I have others DataSets on this thread using the same connection (But simple SELECT statments) that work...

Any Idea?


Thanks!
Eduardo Jauch
2008-03-27 09:22:47 UTC
Permalink
Well...

It seens that I solve the problem...

One thing was that the FCarsConnection was not activated on time I was
doing this:

FCarsDocLDS := TSQLDataSet.Create(nil);
FCarsDocLDS.SQLConnection := FCarsConnection;
FCarsDocLDS.CommandType := ctStoredProc;
FCarsDocLDS.CommandText := 'msDocL';
FCarsDocLDS.Params.CreateParam(ftInteger, '@idDocAM', ptInputOutput);


So, I change this piece of code to:

FCarsDocLDS := TSQLDataSet.Create(nil);
FCarsDocLDS.CommandType := ctStoredProc;
FCarsDocLDS.SQLConnection := FCarsConnection;
FCarsDocLDS.SchemaName := 'dbo';
FCarsDocLDS.Params.CreateParam(ftInteger, '@idDocAM', ptInputOutput);

And the second piece of code to:

with FCarsDocLDS do
begin
if Active then
Close;

CommandText := 'msDocL';
ParamByName('@idDocAM').AsInteger :=
FCarsDocAMDS.FieldByName('idDocAM').AsInteger;

Open;
First;
end;

And this solved the problem...

Loading...