I've been trying to display sqlite data in wxcomboboxes but I get a type error not all arguments converted during string formatting, I'm Using a caller for the frame and it displays for about five comboBoxes but when I add more (exactly the same way as the first ones) It gives me that error am I doing something wrong or is there a problem with sqlite?. my code works like this: Select*for store where Id = ? Self.frmedit.combo.setvalue frmedit.show (frmedit is a frame with some comboboxes & txtctrls) if i can get an example of displaying large data sets with textctrl and comboboxes that will be good too all I've seen so far are listctrls.

It gives me that error am I doing something wrong

We don't know what the error is so there is no way to answer other than to ask what happens if nothing is found in the data base. Try printing the look up before adding to the combobox.

Edited 4 Years Ago by woooee

I said I get a "TYPE ERROR: not all arguments converted during string formatting", it works properly when I have 1 to 5 comboboxes or txtctrls in my frame when I add more I get the error

"I get a Type Error" tells nothing about the why. You must post the entire error message, which shows the offending line and the place in the line where the error occurs. If you use the exact same code to create all boxes using a loop or calling the same function (we don't know), then it is not related to ComboBox creation. Wx has been around for years so I seriously doubt that it has anything to do with Wx code that creates the ComboBoxes, but is instead related to the data, all other things being equal. Once again, print the result of the select statement, and/or use a different set of data to test with which should produce the error at a different place or not at all if your program uses the same code to create all boxes.

Comments
well said
[(7, u'KING', u'ROBERT')]
Traceback (most recent call last):
  File "C:\Python27\code\chidimez\tstcode\employees.py", line 923, in OnEdit
    self.OnOpenEdit(sSQL,iEmployees)
  File "C:\Python27\code\chidimez\tstcode\employees.py", line 951, in OnOpenEdit
    sParameter ='Input parameter: %s ' %(sSQL,sParameter)
TypeError: not all arguments converted during string formatting

"""function from my imported module data.py"""


 def OnQueryParmeter(sSQL,sParameter):

  try:
            conn = sqlite3.connect(dbName,isolation_level=None)    
            cur = conn.cursor()
            Parameter =(sParameter,)            
            cur.execute(sSQL,Parameter)    
            rsRecordSet = cur.fetchall()    
            cur.close()    
            conn.close()

  return rsRecordSet



"""iEmployees=selcted item in a listctrl"""
The code:
 sSQL='SELECT * FROM Employees WHERE EmployeeID = ?'
            self.OnOpenEdit(sSQL,iEmployees)



   def OnOpenEdit(self,sSQL,sParameter):

   try:
            """Retrive data for the selected product."""
            rsEmployees = data.OnQueryParmeter(sSQL,sParameter)
            print rsEmployees
            """Create an istance of the Child_Frame"""
            self.frmEdit = self.frmEdit = frmUpdate_Employees(caller_frmUpdate = self)
            """"Populate the fields of the frame with the recordset."""
            for i in rsEmployees:
                self.frmEdit.txEmployeeID.SetValue(strip(str(i[0])))
                self.frmEdit.txLastName.SetValue(strip(str(i[1])))
                self.frmEdit.txFirstName.SetValue(strip(str(i[2])))
                """The title of the frame."""
                sEmployees =(strip(str(i[1])))               
            print rsEmployees
            sTitle = 'Select Employee: %s' % (sEmployees)
            self.frmEdit.SetTitle(sTitle)
            self.frmEdit.Show()
            self.frmEdit.Center()

File "C:\Python27\code\chidimez\tstcode\employees.py", line 951, in OnOpenEdit
sParameter ='Input parameter: %s ' %(sSQL,sParameter)
TypeError: not all arguments converted during string formatting

This statement
sParameter ='Input parameter: %s ' %(sSQL,sParameter)
accepts one parameter (one %s) but you supply 2 parameters (sSQL,sParameter). Note that this line does not appear in the code you posted.

yes it doesn't its supposed to be an except statement to catch errors in the try statement worked well so far except here.i

i finally found the error!the except statement didn't let me see the errors in the try stmt i just removed both the try and except clauses and my code works perfectly and for that sParameter i copied two definitions without really understanding it of which one supplies 2 parameters (i jst printed their results) thks for your help.

This question has already been answered. Start a new discussion instead.