How can I execute a stored procedure using sqldatasource and get the return value in vb.net.
Thanks,
Terri
How can I execute a stored procedure using sqldatasource and get the return value in vb.net.
Thanks,
Terri
You need to use a SqlConnection
with a SqlCommand
, like this:
using (var connection = new SqlConnection(connectionString))
using (var command = new SqlCommand("StoredProcedureName", connection)) {
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("SomeParam", someValue);
object result = command.ExecuteScalar();
}
If you already have the SP returning a value then you have to grab the value in the corresponding event for the data source. AKA - Inserted, Selected, etc...
Here's a couple links illustrating the point.