1 (edited by CDB 2020-02-16 09:39:31)

Topic: Problem with SQL Execute syntax.

I'm having a problem getting my SQLExecute statement correct.


I wish to delete from the database an entry I select via a combobox, Like wise I am also looking at editing an entry via combobox selection.


I have tried  SQLExecute('DELETE FROM supplier WHERE sup_name='+ frmMain.ComboBox2.Text);  which produces the syntax error shown in the attached image. I first of all though I should be using dbItemID SQLExecute('DELETE FROM supplier WHERE sup_name='+ frmMain.ComboBox2.dbItemID);, but that just gives me an ID of -1.


The following SQL works in DB Browser for SQLITE FROM supplier WHERE sup_name="Corsair"+"Trading".


Neither actually deletes the  file in the database. Once I understand what I'm doing wrong here, I think my 'update' for editing an entry should follow the same syntax structure.

I'm too far down the track, to change my comboboxes to tablegrids, whcih of course would allow me to use the inbuilt DELETE and UPDATE records.

Post's attachments

Attachment icon MVD_sql_delete.PNG 189.35 kb, 143 downloads since 2020-02-16 

On a clear disk you can seek forever

Re: Problem with SQL Execute syntax.

CDB wrote:

I'm having a problem getting my SQLExecute statement correct.


I wish to delete from the database an entry I select via a combobox, Like wise I am also looking at editing an entry via combobox selection.


I have tried  SQLExecute('DELETE FROM supplier WHERE sup_name='+ frmMain.ComboBox2.Text);  which produces the syntax error shown in the attached image. I first of all though I should be using dbItemID SQLExecute('DELETE FROM supplier WHERE sup_name='+ frmMain.ComboBox2.dbItemID);, but that just gives me an ID of -1.


The following SQL works in DB Browser for SQLITE FROM supplier WHERE sup_name="Corsair"+"Trading".


Neither actually deletes the  file in the database. Once I understand what I'm doing wrong here, I think my 'update' for editing an entry should follow the same syntax structure.

I'm too far down the track, to change my comboboxes to tablegrids, whcih of course would allow me to use the inbuilt DELETE and UPDATE records.

Try this

SQLExecute('DELETE FROM supplier WHERE sup_name="'+ frmMain.ComboBox2.Text + '"'); 
@thezimguy

3 (edited by thezimguy 2020-02-16 15:06:53)

Re: Problem with SQL Execute syntax.

Attach your project or a screenshot of the table if you are still facing challenges

@thezimguy

Re: Problem with SQL Execute syntax.

Thanks for the pointer, the syntax change has solved the error.

On a clear disk you can seek forever