lekso borashvili
lekso borashvili

Reputation: 65

How to solve 07002 too few parameters

I have the following code:

        self.cursor.execute("""UPDATE Names SET Format = ?, FoodServiceBulkPack = ?, EachUPC = ?,
        EachWeight = ?, EachUOM = ?, QtyPerInner = ?, InnerPackUPC = ?, InnerWeight = ?,
        InnerUOM = ?, QtyPerCase = ?, CaseUPC = ?, CaseWeight = ?, CaseUOM = ?,
        QtyCasesperPallet = ?, CaseGTIN = ?, [Short Description] = ?, [Long Description] = ?,
        FrontImage = ?, RearImage = ?, Layflat = ?, Perishable = ?,
        IsMultiPack = ?, IsVarietyPack = ?, IsDisplayShipper = ?, PalletUPC = ?, PalletWeight = ?, PalletUOM = ?,
        PalletTi = ?, PalletHi =  = ?
        WHERE ((BrandName = """ + brandName + 
        ") AND ([ProductStyle /Category] = " + productStyle + 
        ") AND (ProductFlavor = " + productFlavor + ")) """, conv_list)
        self.con.commit()

I made sure number of elements in conv_list is the same as question marks. However, I get the following problem

    self.cursor.execute("""UPDATE Names SET Format = ?, FoodServiceBulkPack = ?, EachUPC = ?,   
    pyodbc.Error: ('07002', '[07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. 
    Expected 64. (-3010) (SQLExecDirectW)')          

Upvotes: 0

Views: 44

Answers (1)

Gustav
Gustav

Reputation: 55816

Too many quotes, I guess. Try with:

    self.cursor.execute("UPDATE Names SET [Format] = ?, FoodServiceBulkPack = ?, EachUPC = ?,
    EachWeight = ?, EachUOM = ?, QtyPerInner = ?, InnerPackUPC = ?, InnerWeight = ?,
    InnerUOM = ?, QtyPerCase = ?, CaseUPC = ?, CaseWeight = ?, CaseUOM = ?,
    QtyCasesperPallet = ?, CaseGTIN = ?, [Short Description] = ?, [Long Description] = ?,
    FrontImage = ?, RearImage = ?, Layflat = ?, Perishable = ?,
    IsMultiPack = ?, IsVarietyPack = ?, IsDisplayShipper = ?, PalletUPC = ?, PalletWeight = ?, PalletUOM = ?,
    PalletTi = ?, PalletHi = ?
    WHERE ((BrandName = '" + brandName + "') AND ([ProductStyle /Category] = " + productStyle + ") AND (ProductFlavor = '" + productFlavor + "'))", conv_list)
    self.con.commit()

If ProductStyle is text, it must also be quoted like Brandname.

Upvotes: 1

Related Questions