smartglass
IS-IT--Management
Hi:
I have a MySql table 'customer' containing 2 columns: code (integer) and name (String).
I want users to find details about the customer by calling from the drop down comboBox, but if the combo box is a list of names the SELECT query returns a SQL error; if the combobox comprises codes then I am fine.
THus "SELECT * FROM customer WHERE name=" + jComboBox1.getselectedItem()); fails
whereas "SELECT * FROM customer WHERE code=" + jComboBox2.getselectedItem()); succeeds
where comboBox 1 is a list of names and comboBox2 codes.
It will be unhelpful if I force users to use codes as a reference; is there anything I am missing that allows insertion of text into the select statement?
Thanks!!
I have a MySql table 'customer' containing 2 columns: code (integer) and name (String).
I want users to find details about the customer by calling from the drop down comboBox, but if the combo box is a list of names the SELECT query returns a SQL error; if the combobox comprises codes then I am fine.
THus "SELECT * FROM customer WHERE name=" + jComboBox1.getselectedItem()); fails
whereas "SELECT * FROM customer WHERE code=" + jComboBox2.getselectedItem()); succeeds
where comboBox 1 is a list of names and comboBox2 codes.
It will be unhelpful if I force users to use codes as a reference; is there anything I am missing that allows insertion of text into the select statement?
Thanks!!