0
votes

I have been trying to use SQL with PYQT4 to update an access database with information a user has inputted into my program. I don't want to update all of the records just a specific record and a specific amount of columns (5 out of the 10 columns). however, I keep getting an error that reads:

"pyodbc.Error: ('07002', '[07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 6. (-3010) (SQLExecDirectW)')"

I can't seem to resolve it.

Here is my code:

SelectDatabase.execute('UPDATE Order_Table SET DateDue=(dateDueString), TimeDue=(timeDueString), PaymentType=(paymentExp), Paid=(paidExp), Customer_ID=(customerExp) WHERE OrderLine_ID=(orderlineExp)') 

The values inside the brackets are variables that I have created and I am trying to call upon them, I have proof checked them multiple times, including spell checking them and I can't find a problem in that regard.

If anyone has any ideas or needs more information please let me know.

2
suggest you include the code that defines the parameters. are there mandatory (not null) columns in the table? could any of those be missing from your update statement? - Paul Maxwell
I have no mandatory columns in my table, so I can have null values at this moment in time - Jacob B.
Your statement requires values for the names placeholders. Have you provided values? - Bohemian
All of the variables I have called upon to update a column with are linked to a string value that the user will input into my code. For example, the 'dateDueString' is a string that has been converted from the QtDate format and 'paidExp' is Boolean value. - Jacob B.

2 Answers

1
votes

I have managed to figure out the problem. I was trying to use a variable within my SQL which once I had formatted differently worked straight away this is what I changed it to.

  SelectDatabase.execute('UPDATE Order_Table SET DateDue=?, TimeDue=?, PaymentType=?, Paid=?, Customer_ID=? WHERE OrderLine_ID=?', dateDueString,timeDueString,paymentExp,paidExp,customerExp,orderlineExp)

This way by changing the values to unknowns inside the SQL procedure and referencing them in order after the edit allowed for the string values of the variables to be found and the correct columns to be edited.

Thank-you for trying to help.

0
votes

Well i guess you need create your stored procedure in SQL first with all parameters and then simply call it.

Exec dbo.mYParameter 'timeDueString','paymentExp','paidExp','customerExp','orderlineExp'