Topic: How to delete a database item from a combobox
Hello,
I am having a problem working out how to delete an item in a database from an entry in a combobox.
What I'm trying to do is to select an item from a combobox and then click on a button to delete the entry out of both the database and the combobox itself.
The code I currently have is:
procedure frmMain_btnDeleteSupplier_OnClick (Sender: TObject; var Cancel: boolean);
var
item: integer;
idx:string;
begin
idx := frmMain.ComboBox2.text; //get the entry selected from the combobox
{ frmMain.ComboBox2.dbDeleteRecord(16);} // I feel I should be able to use this somehow
showmessage('Item ' + idx); // shows a message box just for debugging purposes. At this point the correct item shows in the message
frmMain.ComboBox2.dbSQLExecute('DELETE FROM supplier WHERE sup_name =' + idx); //Delete the selected item from the database
frmMain.ComboBox2.dbUpdate; //Update the database and possibly the combobox
end;
One of my problems is, the above SQL produces and error message 'no such column: item text that I've selected
If someone could point me in the right direction I'd be very grateful.
Do I need to somehow read in the row ID from the DB and then use 'dbDeleteRecord(rowID)'? If so I'm not sure how to do that in MVD.
I am using the trial version 6.1.