Hey everyone, I just started doing some coding in VB.Net with Visual Studio 2005. I need some help please! Basically on my form I have a new datagrid called DGBcs, I want this to populate with data from the stored procedure that accepts a parameter from another form. I would like the datagrid to populate once the form is opened. Here is my code right now I get a long error message but saying Procedure 'usp_ReturnWomenHData' expects parameter '@MsfcNumV', which was not supplied, I am pretty sure I am suppling it but I must have it wrong somewhere. Thanks for all your help!
Private Sub FrmWomensHealth_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyConnection As New SqlConnection My.Settings.MemberManagerConnectionString)
Dim MyCommand As New SqlCommand("usp_ReturnWomenHData", MyConnection)
MyCommand.CommandType = CommandType.StoredProcedure
Try
Dim MsfcNumV As New SqlParameter("@MsfcNumV", SqlDbType.VarChar)
MsfcNumV.Direction = ParameterDirection.Input
MsfcNumV.Value = FrmMainMenu.txtMsfcNum.Text
MyCommand.Parameters.Add(MsfcNumV)
MyConnection.Open()
Dim WomenHAdapter As SqlDataAdapter = New SqlDataAdapter("usp_ReturnWomenHData", MyConnection)
Dim BreastCancer As DataSet = New DataSet
WomenHAdapter.Fill(BreastCancer, "usp_ReturnWomenHData")
DgBcs.DataSource = BreastCancer
MyConnection.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Private Sub FrmWomensHealth_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyConnection As New SqlConnection My.Settings.MemberManagerConnectionString)
Dim MyCommand As New SqlCommand("usp_ReturnWomenHData", MyConnection)
MyCommand.CommandType = CommandType.StoredProcedure
Try
Dim MsfcNumV As New SqlParameter("@MsfcNumV", SqlDbType.VarChar)
MsfcNumV.Direction = ParameterDirection.Input
MsfcNumV.Value = FrmMainMenu.txtMsfcNum.Text
MyCommand.Parameters.Add(MsfcNumV)
MyConnection.Open()
Dim WomenHAdapter As SqlDataAdapter = New SqlDataAdapter("usp_ReturnWomenHData", MyConnection)
Dim BreastCancer As DataSet = New DataSet
WomenHAdapter.Fill(BreastCancer, "usp_ReturnWomenHData")
DgBcs.DataSource = BreastCancer
MyConnection.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub