0

as may be quiet aparent, i have very little experience with SQL queries.

I'm having problems with the following Query that i'm generating within my Vb.net application

UPDATE Payments SET B1Code = '12345', ARInvoice = '54321', INV2Go = '00000' WHERE PatientID = '400' AND Product = 'Consultation' AND Catagory = 'Orthotics'

(i have created a test record in the database matching the above information)

Its being constructed with the following code in vb.net:

Dim query As String = "UPDATE Payments SET B1Code = '" & txtB1Code.Text & "', ARInvoice = '" & txtARInvoice.Text & "', INV2Go = '" & txtInv2GoCode.Text & "' WHERE PatientID = '" & Integer.Parse(txtID.Text) & "' AND Product = '" & txtProduct.Text & "' AND Catagory = '" & txtPatientType.Text & "'"

Then being passed the my execute query function like this:

DatabaseFunctions.ExecuteQuery(query)

and the function:

Public Shared Sub ExecuteQuery(ByVal SQL As String)

    CheckConnection()
    Dim cmd As New OdbcCommand(SQL, con)
    cmd.ExecuteNonQuery()

End Sub

The function works perfectly, i've used it time and time again for creating/editing records using simple sql queries built in similar ways as above.. The problem is this particular query returns an error:

ERROR [07002ض] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

Maybe someone with more sql experience than me can see what i'm missing ?

Thanks

Element
  • 95
  • 9
  • ` PatientID = '" & Integer.Parse(txtID.Text) & "'` if patientID is integer pass like this `PatientID = " & Integer.Parse(txtID.Text) & "` – Sathish Feb 18 '14 at 09:27
  • Thanks - this addressed my second issue i ran into after Serv's suggestion – Element Feb 18 '14 at 09:42

1 Answers1

1

This error indicates, that one of the columsn you use in your query does not exist.

Check your query again: did you mean Catagory OR Category ?

Marco
  • 22,856
  • 9
  • 75
  • 124
  • Thanks, i found the problem one of the columns in my query was spelled incorrectly- but this now leads to another error: – Element Feb 18 '14 at 09:38
  • ERROR [22018ٓ] [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. – Element Feb 18 '14 at 09:39