Im having a problem using a parameter as part of the SELECT statement. Can someone please help me to understand why I get the following error;
"The OleDbParameterCollection only accepts non-null OleDbParameter type objects, not String objects"
Thanks in advance for the help.
*********** Here is the code *******************************
Dim daStudy As New OleDbDataAdapter("SELECT * FROM tblStudy WHERE StudyID = @StudyID", conSmallGrp)
Dim dsStudy As New DataSet
Me.ShowStudy(ddlStudy.SelectedItem.Value)
Private Sub ShowStudy(ByVal StudyID As Integer)
daStudy.SelectCommand.Parameters.Add("@StudyID")
daStudy.SelectCommand.Parameters("@StudyID").Value = StudyID
Fill dataset that will be used to populate text boxes
daStudy.Fill(dsStudy, "tblStudy")
txtStudyID = dsStudy.Tables("tblStudy").Rows(0).Item("StudyID")
txtCategory = dsStudy.Tables("tblStudy").Rows(0).Item("CategoryID")
txtBookTitle = dsStudy.Tables("tblStudy").Rows(0).Item("Book")
txtAuthor = dsStudy.Tables("tblStudy").Rows(0).Item("Author")
txtISBN = dsStudy.Tables("tblStudy").Rows(0).Item("Isbn")
txtSummary = dsStudy.Tables("tblStudy").Rows(0).Item("Summary")
End Sub
"The OleDbParameterCollection only accepts non-null OleDbParameter type objects, not String objects"
Thanks in advance for the help.
*********** Here is the code *******************************
Dim daStudy As New OleDbDataAdapter("SELECT * FROM tblStudy WHERE StudyID = @StudyID", conSmallGrp)
Dim dsStudy As New DataSet
Me.ShowStudy(ddlStudy.SelectedItem.Value)
Private Sub ShowStudy(ByVal StudyID As Integer)
daStudy.SelectCommand.Parameters.Add("@StudyID")
daStudy.SelectCommand.Parameters("@StudyID").Value = StudyID
Fill dataset that will be used to populate text boxes
daStudy.Fill(dsStudy, "tblStudy")
txtStudyID = dsStudy.Tables("tblStudy").Rows(0).Item("StudyID")
txtCategory = dsStudy.Tables("tblStudy").Rows(0).Item("CategoryID")
txtBookTitle = dsStudy.Tables("tblStudy").Rows(0).Item("Book")
txtAuthor = dsStudy.Tables("tblStudy").Rows(0).Item("Author")
txtISBN = dsStudy.Tables("tblStudy").Rows(0).Item("Isbn")
txtSummary = dsStudy.Tables("tblStudy").Rows(0).Item("Summary")
End Sub