First of all, I'd like to say hello to the Daniweb community as a first-time poster. I'm sorry if this is a common error for you folks to deal with, but my preliminary search of the forum didn't really help me all that much. So here we are.
Onwards to the issue. I'm trying to insert a record into an MS Access 2007 database using Visual Basic 2008. Here's the code in question:
Public Function InsScoutInfo(ByVal ScoutInfoObject As ScoutInfo) As Boolean
Dim MaxID As Integer = SelMinMax("Max", "ScoutID", "ScoutInfo", "")
If MaxID = 0 Then
MaxID = 10000
Else
MaxID += 1
End If
Dim RowsAffected As Integer = 0
Dim strInsert As String = "Insert Into ScoutInfo " & _
"(ScoutID, YearID, GSUSAID, FName, LName, DoB, Grade, Level, School, YearsIn, CurrentYear) " & _
"Values (" & _
MaxID & ", " & ScoutInfoObject.YearID & ", " & _
ScoutInfoObject.GSUSAID & ", '" & ScoutInfoObject.FName & "', '" & _
ScoutInfoObject.LName & "', '" & ScoutInfoObject.DoB & "', '" & _
ScoutInfoObject.Grade & "', '" & ScoutInfoObject.Level & "', '" & _
ScoutInfoObject.School & "', " & ScoutInfoObject.YearsIn & ", '" & _
ScoutInfoObject.CurrentYear & "')"
Dim insCommand As New OleDbCommand(strInsert, conDBConnect)
conDBConnect.Open()
RowsAffected = insCommand.ExecuteNonQuery
conDBConnect.Close()
If RowsAffected > 0 Then
Return True
Else
Return False
End If
End Function
When insCommand.ExecuteNonQuery is executed, an exception with Error # -2147217900 is thrown, with the detail of "In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user."
At the time the error is thrown, this is what resides in strInsert: "Insert Into ScoutInfo (ScoutID, YearID, GSUSAID, FName, LName, DoB, Grade, Level, School, YearsIn, CurrentYear) Values (10000, 20092010, 123456, 'Jacobina', 'Lowe', '11/30/2009', 'K', 'Daisy', 'Thisone', 0, '20092010')" I've already verified that the Insert statement and datatypes of the columns match.
Any thoughts or ideas would be appreciated. :)
~Jacob