General information
Title:
How to call store procedure with parameter
My store procedure was contained:
CREATE PROCEDURE [usp_showdepartment] @mHostCode CHAR AS
SELECT * FROM Department WHERE HostCode = @mHostCode ORDER BY DepartmentName
GO
How to call it from vb.net code? .. I tried below codes but I got nothing
Private Sub LoadDepartment()
Dim mHostCode As String = UCase(HostCode.Text.Trim)
Dim SQLDataAdapter As New SqlClient.SqlDataAdapter("usp_showdepartment", SQLConn1)
Dim DSDepartment As New DataSet("Department")
SQLDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
SQLDataAdapter.SelectCommand.Parameters.Add("@mHostCode", SqlDbType.Char)
SQLDataAdapter.SelectCommand.Parameters("@mHostCode").Value = mHostCode
DSDepartment.Clear()
SQLDataAdapter.Fill(DSDepartment, "Department")
Me.C1TrueDBGrid2.DataSource = DSDepartment.Tables("Department")
end sub
please advise ,.. many thanks in advance
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only