Gilles Ganault wrote:
Hello

I'm having a problem saving strings into a colum from a Delphi application because they might contain the ( ' ) single quote character:

=========
// Input := 'Let's meet at the pub tonight!';
MyFormat := 'insert into stuff (title) values ('''%s')';
SQL := Format(MyFormat, Input);

try
    ASQLite3DB1.Database := db;
    ASQLite3DB1.DefaultDir := ExtractFileDir(Application.ExeName);
    ASQLite3DB1.Open;

    ASQLite3DB1.SQLite3_ExecSQL(SQL);
    ASQLite3DB1.Close;
except
    ShowMessage('Bad');
end;
=========

Is there a function I should call either in SQLite or Delphi before running the SQL query?

// Input := 'Let's meet at the pub tonight!';
MyFormat := 'insert into stuff (title) values (%s)';
SQL := Format(MyFormat, QuotedStr(Input));

try
   ASQLite3DB1.Database := db;
   ASQLite3DB1.DefaultDir := ExtractFileDir(Application.ExeName);
   ASQLite3DB1.Open;

   ASQLite3DB1.SQLite3_ExecSQL(SQL);
   ASQLite3DB1.Close;
except
   ShowMessage('Bad');
end;


John

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to