Question

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

Was it helpful?

Solution

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 ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top