dormky 4 Posted Monday at 02:15 PM (edited) query := TMyQuery.Create(nil); query.Connection := conn; query.SQL.Text := 'INSERT INTO documents (key, document) VALUES (:pkey, :pdocument)'; query.ParamByName('pkey').Value := 'key'; query.ParamByName('pdocument').AsBytes := TFile.ReadAllBytes('dummy_1.pdf'); query.Execute(); query.Free(); CREATE TABLE `documents` ( `key` VARCHAR(255) NOT NULL, `document` MEDIUMBLOB); The pdf file : https://www.cte.iup.edu/cte/Resources/PDF_TestPage.pdf For some reason, without the key field this works perfectly fine, but with it I get the error : EMySqlException with message '#42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, document) VALUES ('key', '%PDF-1.4\n%äüöß\n2 0 obj\n<</Length 3 0 R/Fil' at line 1'. Does anyone have any idea of what forsaken bullshit is going on ? It doesn't look like an escape character issue AFAIK as the problem occurs whether the key parameter is in front of the document parameters or after it. I think it's because delphi is casting the pdf file as text but I'm not sure. Edit : I'm blind. Since MyDAC forces you to write SQL statements by hand, I forgot about the `. Gotta hate on bad error messages 🙂 Edited Monday at 02:30 PM by dormky Share this post Link to post