ADO.NET Code executing stored procedure.
Code showing how to fetch data using Stored Procedure.
Imports System
Imports System.Data
Imports System.Data.SqlClient
Private Function FillForm()
Dim myConn As New SqlConnection()
Dim Parm As New SqlParameter()
Dim dr As SqlDataReader
myConn.ConnectionString = "data source=(local);initial catalog=Jobs;integrated security _
=SSPI;persist security info=False;workstation id=XYZ;packet size=4096"
myConn.Open()
Dim cmd As SqlCommand = New SqlCommand("Select_Employer", myConn)
cmd.CommandType = CommandType.StoredProcedure
Parm = cmd.Parameters.Add("@EmployerId", SqlDbType.Int, 9)
Parm.Value = 1
dr = cmd.ExecuteReader()
If (dr.Read = True) Then
txtName.Text = dr("UserName")
end if
dr.Close()
dr = Nothing
cmd.Connection.Close()
myConn.Close()
End Function