lorena
Well-known member
I keep getting this error:
"Number of query values and destination fields are not the same"
I have exactly the same number of fields in my query that are in the database and they are in the same order. I even went so far as to take the parameter values out and substitute hard-coded values and it still throws up. I am not sure what I am doing wrong. Do I have to have a Primary Key for this to work? All this app does is record form data to be exported to a spreadsheet.
Here is my code:
Sub AddRecord()
Dim strConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\intranet\databases\results.mdb"
Dim strSQL, strPlant, strTire, strFilter, strWiper As String
Dim objCommand As OleDb.OleDbCommand
Dim objConn As New OleDb.OleDbConnection(strConnString)
Create SQL String
strSQL = "Insert into PML(Customer, PhoneNo, PlantNo, CarYear, CarMake, CarModel, "
strSQL = strSQL + " DropOff, NeededBy, AirFilter, WiperBlades, Rotation) VALUES "
strSQL = strSQL + " (Ethel Mertz, 555-5555, 1, Toyota, Corolla, 2001, "
strSQL = strSQL + " 730. 430, Y, N, Y)"
objCommand = New OleDb.OleDbCommand(strSQL, objConn)
objConn.Open()
objCommand.ExecuteNonQuery()
objConn.Close()
End Sub
Any help would be appreciated. Thanks
"Number of query values and destination fields are not the same"
I have exactly the same number of fields in my query that are in the database and they are in the same order. I even went so far as to take the parameter values out and substitute hard-coded values and it still throws up. I am not sure what I am doing wrong. Do I have to have a Primary Key for this to work? All this app does is record form data to be exported to a spreadsheet.
Here is my code:
Sub AddRecord()
Dim strConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\intranet\databases\results.mdb"
Dim strSQL, strPlant, strTire, strFilter, strWiper As String
Dim objCommand As OleDb.OleDbCommand
Dim objConn As New OleDb.OleDbConnection(strConnString)
Create SQL String
strSQL = "Insert into PML(Customer, PhoneNo, PlantNo, CarYear, CarMake, CarModel, "
strSQL = strSQL + " DropOff, NeededBy, AirFilter, WiperBlades, Rotation) VALUES "
strSQL = strSQL + " (Ethel Mertz, 555-5555, 1, Toyota, Corolla, 2001, "
strSQL = strSQL + " 730. 430, Y, N, Y)"
objCommand = New OleDb.OleDbCommand(strSQL, objConn)
objConn.Open()
objCommand.ExecuteNonQuery()
objConn.Close()
End Sub
Any help would be appreciated. Thanks