yablonka Posted May 21, 2003 Posted May 21, 2003 Hello, I created a stored procedure which receive a few parameters and inserts them into the DB according to some conditions, BUT - I'm very new to VB.NET, how do I call the store procedure at runtime and how do I pass the parameters??? Thank you, Quote
*Gurus* Derek Stone Posted May 21, 2003 *Gurus* Posted May 21, 2003 The process is quite similar to executing a SQL statement. Dim oConnection As SqlConnection = New SqlConnection() Dim oConnection As SqlCommand = New SqlCommand() Dim oDataReader As SqlDataReader oConnection.Open() oCommand.CommandType = CommandType.StoredProcedure oCommand.CommandText = "storedProcedureName" oCommand.Connection = oConnection Dim oParameter1 As SqlParameter = oCommand.Parameters.Add("@iInteger", SqlDbType.Int) oParameter1.Value = 1 oDataReader = oCommand.ExecuteReader() While (oDataReader.Read()) ' If the stored procedure does not return rows "oDataReader" is unnecessary ' and a call to "oCommand.ExecuteNonQuery()" or "oCommand.ExecuteScalar()" ' should be used instead End While oDataReader.Close() oConnection.Close() Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.