Hi,
I'm trying to learn how to assign a value to a variable in vb.net (VS2010) using the return from a stored procedure.
I can easily run and pass values to my stored procedures, but I can't find a clear and concise example on how to assign a returned value.
create procedure test
(
@X int,
@Y int OUTPUT
)
as
begin
@y = @x + 1
end
In VB.Net
public sub test()
dim cnn_ODBCLogin as Odbc.OdbcConnection
dim str_ODBCCommand as Odbc.OdbcCommand
cnn_ODBCLogin = New Odbc.OdbcConnection(ConnString)
cnn_ODBCLogin.Open()
str_ODBCCommand.Connection = cnn_ODBCLogin
str_ODBCCommand.CommandText = "text '1'"
str_ODBCCommandType = CommandType.StoreProcedure
str_ODBCCommand.ExecuteNonQuery
...
This all works fine, I've added a record insert into the stored procedure to ensure it runs (it does), but I have no idea how to assign the output value of y to a variable in the VB.Net procedure. Can someone explain how to do this?
Thanks,
iaw
I'm trying to learn how to assign a value to a variable in vb.net (VS2010) using the return from a stored procedure.
I can easily run and pass values to my stored procedures, but I can't find a clear and concise example on how to assign a returned value.
create procedure test
(
@X int,
@Y int OUTPUT
)
as
begin
@y = @x + 1
end
In VB.Net
public sub test()
dim cnn_ODBCLogin as Odbc.OdbcConnection
dim str_ODBCCommand as Odbc.OdbcCommand
cnn_ODBCLogin = New Odbc.OdbcConnection(ConnString)
cnn_ODBCLogin.Open()
str_ODBCCommand.Connection = cnn_ODBCLogin
str_ODBCCommand.CommandText = "text '1'"
str_ODBCCommandType = CommandType.StoreProcedure
str_ODBCCommand.ExecuteNonQuery
...
This all works fine, I've added a record insert into the stored procedure to ensure it runs (it does), but I have no idea how to assign the output value of y to a variable in the VB.Net procedure. Can someone explain how to do this?
Thanks,
iaw