Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored procedure returns value

Status
Not open for further replies.

vasu2005

Programmer
Jul 21, 2005
16
US
Hi all,

I have to call a stored procedure from my VB.NET code , the procedure returns a value(int)

Dim param As OleDbParameter
cmd.Connection = cn 'cmd is oledbcommand object
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "searchitem"

param paramReturnValue = new oledbParameter()
paramReturnValue.ParameterName = "@return_value";
paramReturnValue.oledbType = SqlDbType.Int;
paramReturnValue.Direction = ParameterDirection.ReturnValue;

but I am getting an error on my 5th line that expression is not a method.

Can anyone tell me what is going wrong in my code.

Thanks,

-V
 
V,

This is what works for me, except I'm using SQL Server:

Code:
Dim prmName As SqlParameter = cmd.Parameters.Add("@Param1", SqlDbType.int)
prmName.Value = someNumber

So, I guess yours would be something like this (provided the differences between OleDB and SQL do not change things):

Code:
Dim prmName As OleDBParameter = cmd.Parameters.Add("@Param1", OleDbType.int)
prmName.Value = someNumber

Of course, "@Param1" has to match the parameter name in the stored procedure. Also, before these two lines of code, I've already created connection and commmand.

Hope this helps!
Rudy
 
Code:
param paramReturnValue = new oledbParameter()
paramReturnValue.ParameterName = "@return_value";
paramReturnValue.oledbType = SqlDbType.Int;
paramReturnValue.Direction = ParameterDirection.ReturnValue;

this seems odd??? it looks like C#????

and casting from an oledbtype to an sqldbtype seems odd aswell.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top