How to call stored procedure?

For SQL Server, since you didn't specify. Be sure to provide as much info as possible when asking questions. If you have a different database, then I'll let you figure the changes to make.

VB.NET:
Imports System.Data.SqlClient

Dim param1 As New SqlParameter

Using conn As New SqlConnection("YOUR_CONNECTION_STRING")
     Using cmd As New SqlCommand("sp_your_stored_procedure", conn)
          param1 = cmd.Parameters.Add("@RecordID", SqlDbType.Int)
          param1.Direction = ParameterDirection.Input
          param1.Value = 15

          Using dr As SqlDataReader = cmd.ExecuteReader()

          End Using
     End Using
End Using

If your stored procedure has a parameter, otherwise remove all the parameter code. If you need more parameters, then add them.

CT
 
The default command type is Text, so I think you also need:
VB.NET:
cmd.CommandType = CommandType.StoredProcedure
 
if your sp doesnt return a cursor, i wouldnt executereader it.. scalar or nonquery depending on whether it has a return value or not
 
Back
Top