Вот и пример того, как получить результаты из нашей хранимой процедуры и назначить возвращенные столбцы текстовым полям:
Function GetInfoForStudent(ByRef QueryName As String, ByVal UserName As String, ByVal Password As String) As DataTable
Using Con As New SqlConnection
Try
Using OleCon As New SqlConnection
Dim Connection As String = "MyConnectionString"
Con.Open()
Dim Cmd As SqlCommand = Con.CreateCommand()
Cmd.CommandType = CommandType.StoredProcedure
Cmd.CommandText = QueryName
Cmd.Parameters.AddWithValue("user", UserName)
Cmd.Parameters.AddWithValue("password", Password)
Dim da As New SqlDataAdapter(Cmd)
Dim ds As New DataTable()
da.Fill(ds)
Return ds
End Using
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Using
End Function
Sub ShowStudentInfo()
Dim dt As DataTable = GetInfoForStudent("MyStoredProcName", "MyUserName", "MyPasswword")
' Since (presumably) only one is returned
With dt.Rows(0)
' Assign your text boxes
'LoginIDTextBox.Text = .Item("LoginID")
'StudentNameTextBox.Text = .Item("Student Name")
'StudentAddressTextBox.Text = .Item("Student address")
'StudentIDTextBox.Text = .Item("StudentID")
End With
End Sub