Why do i keep getting a parameter error in my sql update?










0















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.










share|improve this question
























  • 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?

    – Used_By_Already
    Nov 14 '18 at 22:23











  • I have no mandatory columns in my table, so I can have null values at this moment in time

    – Jacob B.
    Nov 14 '18 at 23:24











  • Your statement requires values for the names placeholders. Have you provided values?

    – Bohemian
    Nov 14 '18 at 23:48











  • 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.
    Nov 15 '18 at 7:43















0















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.










share|improve this question
























  • 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?

    – Used_By_Already
    Nov 14 '18 at 22:23











  • I have no mandatory columns in my table, so I can have null values at this moment in time

    – Jacob B.
    Nov 14 '18 at 23:24











  • Your statement requires values for the names placeholders. Have you provided values?

    – Bohemian
    Nov 14 '18 at 23:48











  • 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.
    Nov 15 '18 at 7:43













0












0








0








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.










share|improve this question
















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.







sql ms-access pyodbc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 15:51









eyllanesc

80.2k103258




80.2k103258










asked Nov 14 '18 at 22:16









Jacob B.Jacob B.

113




113












  • 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?

    – Used_By_Already
    Nov 14 '18 at 22:23











  • I have no mandatory columns in my table, so I can have null values at this moment in time

    – Jacob B.
    Nov 14 '18 at 23:24











  • Your statement requires values for the names placeholders. Have you provided values?

    – Bohemian
    Nov 14 '18 at 23:48











  • 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.
    Nov 15 '18 at 7:43

















  • 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?

    – Used_By_Already
    Nov 14 '18 at 22:23











  • I have no mandatory columns in my table, so I can have null values at this moment in time

    – Jacob B.
    Nov 14 '18 at 23:24











  • Your statement requires values for the names placeholders. Have you provided values?

    – Bohemian
    Nov 14 '18 at 23:48











  • 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.
    Nov 15 '18 at 7:43
















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?

– Used_By_Already
Nov 14 '18 at 22:23





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?

– Used_By_Already
Nov 14 '18 at 22:23













I have no mandatory columns in my table, so I can have null values at this moment in time

– Jacob B.
Nov 14 '18 at 23:24





I have no mandatory columns in my table, so I can have null values at this moment in time

– Jacob B.
Nov 14 '18 at 23:24













Your statement requires values for the names placeholders. Have you provided values?

– Bohemian
Nov 14 '18 at 23:48





Your statement requires values for the names placeholders. Have you provided values?

– Bohemian
Nov 14 '18 at 23:48













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.
Nov 15 '18 at 7:43





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.
Nov 15 '18 at 7:43












2 Answers
2






active

oldest

votes


















1














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.






share|improve this answer






























    0














    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'





    share|improve this answer























    • How would I write that in code? And would that fetch the variable value of 'timeDueString', 'paymentType', ect. Because they're not strings but variables that have a string value, that is completely dependent on what a user would enter into my program.

      – Jacob B.
      Nov 15 '18 at 7:39










    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309564%2fwhy-do-i-keep-getting-a-parameter-error-in-my-sql-update%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    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.






    share|improve this answer



























      1














      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.






      share|improve this answer

























        1












        1








        1







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 7:53









        Jacob B.Jacob B.

        113




        113























            0














            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'





            share|improve this answer























            • How would I write that in code? And would that fetch the variable value of 'timeDueString', 'paymentType', ect. Because they're not strings but variables that have a string value, that is completely dependent on what a user would enter into my program.

              – Jacob B.
              Nov 15 '18 at 7:39















            0














            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'





            share|improve this answer























            • How would I write that in code? And would that fetch the variable value of 'timeDueString', 'paymentType', ect. Because they're not strings but variables that have a string value, that is completely dependent on what a user would enter into my program.

              – Jacob B.
              Nov 15 '18 at 7:39













            0












            0








            0







            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'





            share|improve this answer













            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'






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 14 '18 at 23:39









            RaniduRanidu

            192




            192












            • How would I write that in code? And would that fetch the variable value of 'timeDueString', 'paymentType', ect. Because they're not strings but variables that have a string value, that is completely dependent on what a user would enter into my program.

              – Jacob B.
              Nov 15 '18 at 7:39

















            • How would I write that in code? And would that fetch the variable value of 'timeDueString', 'paymentType', ect. Because they're not strings but variables that have a string value, that is completely dependent on what a user would enter into my program.

              – Jacob B.
              Nov 15 '18 at 7:39
















            How would I write that in code? And would that fetch the variable value of 'timeDueString', 'paymentType', ect. Because they're not strings but variables that have a string value, that is completely dependent on what a user would enter into my program.

            – Jacob B.
            Nov 15 '18 at 7:39





            How would I write that in code? And would that fetch the variable value of 'timeDueString', 'paymentType', ect. Because they're not strings but variables that have a string value, that is completely dependent on what a user would enter into my program.

            – Jacob B.
            Nov 15 '18 at 7:39

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309564%2fwhy-do-i-keep-getting-a-parameter-error-in-my-sql-update%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3

            Museum of Modern and Contemporary Art of Trento and Rovereto