Page 1 of 1

Parameter of stored procedure lost...

Posted: Tue 05 Jul 2011 06:30
by BigAl66
Hi,

I have a small problem:

I open a stored procedure using the TMSStoredProc object. Everything works fine. Only the parameters I specified where lost all the times. When I open the MSStoredProc Editor and specify my parameters I can access my data. When I close the editor and open it again, the parameters where set to "NULL".

Is it a bug?

Alex

Posted: Tue 05 Jul 2011 09:42
by AndreyZ
Hello,

The point is that SDAC uses the @ symbol for working with parameters. To avoid both problems (here and http://www.devart.com/forums/viewtopic.php?t=21420), you should alter your procedure in the following way:

Code: Select all

ALTER PROCEDURE [dbo].[] 
@xxx INT 
AS 
BEGIN
...
After this, to access a parameter by name, you should use the following code:

Code: Select all

MSStoredProc.ParamByName('xxx').AsString := 'test';

Posted: Tue 05 Jul 2011 09:59
by BigAl66
Hi,

this do only partly work. The parameter will no not be lost anymore. But I can still not access it. I get always the error "Parameter 'xxx' not found'... :(

Any other idea?

Alex
AndreyZ wrote:Hello,

The point is that SDAC uses the @ symbol for working with parameters. To avoid both problems (here and http://www.devart.com/forums/viewtopic.php?t=21420), you should alter your procedure in the following way:

Code: Select all

ALTER PROCEDURE [dbo].[] 
@xxx INT 
AS 
BEGIN
...
After this, to access a parameter by name, you should use the following code:

Code: Select all

MSStoredProc.ParamByName('xxx').AsString := 'test';

Posted: Tue 05 Jul 2011 11:35
by AndreyZ
Please try using the following code:

Code: Select all

MSStoredProc.StoredProcName := 'stor_proc_name';
MSStoredProc.PrepareSQL;
MSStoredProc.ParamByName('xxx').AsString := 'test';
MSStoredProc.Open;

Posted: Tue 05 Jul 2011 12:07
by BigAl66
Hi,

I found the problem. Changing the procedure in the SQL-Server will not update the call parameters in the TMSStoredProc object. After I changed to another stored procedure and go back to original one, the parameters look ok.

Thank you verry much for your fast and professional help!

Alex
AndreyZ wrote:Please try using the following code:

Code: Select all

MSStoredProc.StoredProcName := 'stor_proc_name';
MSStoredProc.PrepareSQL;
MSStoredProc.ParamByName('xxx').AsString := 'test';
MSStoredProc.Open;

Posted: Tue 05 Jul 2011 12:33
by AndreyZ
It is good to see that this problem was solved. If any other questions come up, please contact us.