Need help to solve MySQL Query problem lazarus / 16-Databases ---------------------------------------------------------------------- mandeepmavi · 2012-03-14 08:21 Hi need help to remove this error I am using below query to insert in to MySQL Table. But if the value of dbTable.FieldByName('V4').AsString = 10" Knife used IT give me SQL error and do not excute. TxtQ:='INSERT INTO Table (H0,H1) VALUES ("'+      Edit1.Text+'","'+dbTable.FieldByName('V4').AsString+'")';  dbTrabajo.SQL.Text:=TxtQ; dbTrabajo.ExecSQL; But if i use       dbTable.FieldByName('V4').AsString = 10 inch Knife used it works fine. I think MySQL is giving problem due to inch sign " . How to solve this please help. Mandeep Mavi ---------------------------------------------------------------------- paweld · 2012-03-14 11:42 Code: [Select]TxtQ:='INSERT INTO Table (H0,H1) VALUES ('''+Edit1.Text+''','''+dbTable.FieldByName('V4').AsString+''')'; dbTrabajo.SQL.Text:=TxtQ; dbTrabajo.ExecSQL; ---------------------------------------------------------------------- BigChimp · 2012-03-14 12:01 And if you do either of those, watch out for values like QuoteBob's Fabulous 12" Steak Knife Hint: look at parametrised queries (the wiki has an article on it). Also, choosing the column to insert values for based on an editbox seems... optimistic. What if the user misspells the column name? A combo box or similar would make more sense... ---------------------------------------------------------------------- mandeepmavi · 2012-03-16 19:22 Unable to solve ---------------------------------------------------------------------- Lacak2 · 2012-03-19 07:38 You must use something like: Code: [Select]dbTrabajo.SQL.Text:='INSERT INTO Table (H0,H1) VALUES (:H0,:H1)'; dbTrabajo.ParamByName('H0').AsString:=Edit1.Text; dbTrabajo.ParamByName('H1').AsString:=dbTable.FieldByName('V4').AsStri ng; dbTrabajo.ExecSQL; ---------------------------------------------------------------------- mandeepmavi · 2012-04-01 16:27 It work, do some testing