Stored Proedure
-
How to Call Stored Procedure from SQL 2005 to VB.Net 2008
Hafiz Mudasir Hussain Software Engineer Pakistan
-
How to Call Stored Procedure from SQL 2005 to VB.Net 2008
Hafiz Mudasir Hussain Software Engineer Pakistan
You call it the same way you would execute a plain old SQL statement: with a SqlCommand or a SqlDataAdapter. For instance, if you had a stored procedure called ListUsersByRole which took a single parameter, you might do something like this to retrieve all admin users:
dim cmd as new SqlCommand(yourConnection, "exec ListUsersByRole 'admin'")
dim dr as DbDataReader = cmd.ExecuteReader()
while dr.Next()
Console.WriteLine(dr("username"))
end while
dr.Close() -
How to Call Stored Procedure from SQL 2005 to VB.Net 2008
Hafiz Mudasir Hussain Software Engineer Pakistan
1. Assuming you only want to know about the rows affected
using cn as new sqlconnection("ConnectionStringHERE")
dim cmd as new sqlcommandcmd.connection = cn
cmd.commandType = StoredProc
cmd.commandText = "MyStoredProc"dim Results as integer = cmd.executenonQuery
end usingI would also look up
SQLParameters
andSQLDataAdapters
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch