* * *

Author Topic: DELETE sql  (Read 441 times)

puredeadoblivion

  • New member
  • *
  • Posts: 18
DELETE sql
« on: March 13, 2017, 05:41:35 pm »
Hello all,

I'm having trouble with deleting from a database, it is throwing the error ' error near DELETE', but I can's see why

Code: Pascal  [Select]
  1.  else if cbAction.text='Delete' then
  2.  begin
  3.    SQLQuery1.close;
  4.    SQLQuery1.SQL.add('DELETE FROM Deck2 WHERE Deckname = :DECKNAM');  
  5.    SQLQuery1.Params.ParamByName('DECKNAM').AsString:=cbDeck.text;
  6.    SQLQuery1.active:=true;
  7.    SQLQuery1.execSQL;
  8.    SQLQuery1.close;
  9.  end;
  10.  


Thanks

paweld

  • Full Member
  • ***
  • Posts: 154
Re: DELETE sql
« Reply #1 on: March 13, 2017, 06:17:18 pm »
Code: Pascal  [Select]
  1. else if cbAction.text='Delete' then
  2.  begin
  3.    if SQLQuery1.Active then
  4.    SQLQuery1.close;
  5.    SQLQuery1.SQL.Clear;
  6.    SQLQuery1.SQL.add('DELETE FROM Deck2 WHERE Deckname = :DECKNAM');  
  7.    SQLQuery1.Params.ParamByName('DECKNAM').AsString:=cbDeck.text;
  8.    SQLQuery1.execSQL;
  9.  end;
Best regards
paweld

puredeadoblivion

  • New member
  • *
  • Posts: 18
Re: DELETE sql
« Reply #2 on: March 13, 2017, 06:32:45 pm »
Well its no longer throwing the same error, it now says that the sql is not set

goodname

  • Sr. Member
  • ****
  • Posts: 282
Re: DELETE sql
« Reply #3 on: March 13, 2017, 06:37:16 pm »
This will clear out old queries and set the new one.
Code: Pascal  [Select]
  1. SQLQuery1.SQL.Text := 'DELETE FROM Deck2 WHERE Deckname = :DECKNAM';

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus