Discussion:
problem with StoredProcs with more than one parameter
(too old to reply)
Eduardo
2008-05-27 17:10:35 UTC
Permalink
Hi!

I'm trying to execute a Stored procedure on a MS SQL Server 2000 database (I'm using the Delphi 2007 Trial version).

The problem is that I cannot execute any Stored Proc with more than One (1) parameter that I receive a message that tell that the other parameters weren't supplied (only the first).

This happens on machines where the Delphi isn't installed.
On the machine where I work All runs ok.

I tried to create the parameters, but without success...
Continues working on my machine and not on others...

Anyone can help me?
Dennis Passmore
2008-05-27 21:02:26 UTC
Permalink
Can you give us a little bit of the Create Procedure information of how
you are defining the parameters and then how you are trying to execute
it from the Delphi code
Eduardo Jauch
2008-05-27 22:56:46 UTC
Permalink
Of course!

I have a TSQLConnection linked to a SQLServer 2000.
A TSQLDataSet, linked to this Connection, with the name of the stored procedure (ms_Teste).

The stored procedure is like this:

create procedure ms_Teste
@Id as varchar(12),
@Nome as varchar(12)
as

Select * from wtDocAM
Where convert(varchar(12), idDocAM) Like @Id and Num Like @Nome
Go

I have an TDataSetProvider linked to this TSQLDataSet and a TSQLClientDataSet linked to the TDataSetProvider.
A TDataSource linked to the TSQLClientDataSet and finally a DBGrid linked to the TDataSource

Something like this

TSQLConnection
|
TSQLDataSet
|
TSQLDataSetProvider
|
TSQLClientDataSet
|
TSQLDataSource
|
TDBGrid

I put two TEdit and a Button on the Form.
Only the TSQLConnection is activated.

When the user press the button, this code is executed (this is the only code on the program):

var
Temp: String;

begin
ClientDataSet1.Close;

if Edit1.Text = '' then
Temp = '%'
else
Temp = Edit1.Text;

SQLDataSet1.Params[0].AsString = Temp;

if Edit2.Text = '' then
Temp = '%'
else
Temp = Edit2.Text;

SQLDataSet1.Params[1].AsString = Temp;

ClientDataSet1.Open;
end;


For test on computer 1 (with Delphi installed), I executed the program and put
on Edit1: 8%
on Edit2: a%

Press the button and get the DBGrid fill with many rows from the database.

On the computer where I don't have the Delphi installed, I do the same, but receive a message telling: 'Procedure 'ms_Teste' expects parameter '@Nome', which was not supplied'

This error is generated by the SQL Server.

I then executed a Tracer with the SQL Profile, and found that to the SQL Server, on the computer without the Delphi installed, only the SECOND parameter was supplied (not the first, @Id), but he thinks that the missing was the Second.

On computer with delphi installed, both parameters were supplied.

I observed the TSQLDataSet. He corrects found the two parameters, but for any reason, pass only the last parameter.

I not test yet, but I think that probably he is passing only the last of the parameters, no matter how many are.

Because no DLL was asked, I think that none is missing.
dbxmss30.dll I supplied with the program. If it is not present, I get an error when the programs try to connect to database.

The Midas.dll I put inside the code, puting the MidasLib on the Uses (because I alread have an error with a different version of Midas on yet other machine, with other program).

For a test, I translate the code to C, and executed.
Again, on the computer with Delphi (RAD) instaled, all works perfectly.

On the other machine, only the last parameter is passed...

Because Stored Procedures works ok, and We have others programs that uses it a lot (commercial programs), and because on the sql server, I can use these sp with many parameter without error, I think that can be some Lib on these computers that are old or incompatible versions...

Only this can explain this...

But I can't find what is...

Do you have this problem or see it yet?

I really need to make this work, but can't find a workaround...
Eduardo
2008-05-28 12:30:24 UTC
Permalink
News...

I changed the TSQLConnection and TSQLDataSet to TADOConnection and TADODataSet and make a test.

Work perfectly.

So, I think that the problem is really with DBExpress.

I'll have to change my application to use ADO insted DBExpress, until I can figure out what is going on...
Loading...