I am working on one issue where I need to insert
multiple records using TSQLQuery
at once in my Mysql
Database.
Below is Testing code:
var
LSQLQuery : TSQLQuery;
begin
LSQLQuery:=TSQLQuery.Create(nil);
try
LSQLQuery.SQLConnection:=SQLConnection1;
LSQLQuery.SQL.Add('Insert into TestTable(P_ID, F_Name, L_Name) values (2,"Vijay", "Chauhan");');
LSQLQuery.SQL.Add('Insert into TestTable(P_ID, F_Name, L_Name) values (4,"raj", "Chauhan");');
LSQLQuery.SQL.Add('Insert into TestTable(P_ID, F_Name, L_Name) values (5,"XXX", "Chauhan");');
LSQLQuery.ExecSQL;//Execute the query
finally
LSQLQuery.Free;
end;
end;
I dont know whats wrong I am doing but everytime I execute this I get the error as follows:
--------------------------- Debugger Exception Notification ---------------------------
Project Test.exe raised exception class TDBXError with message 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Insert into TestTable(P_ID, F_Name, L_Name) values (2,'Vijay', 'Chauhan'); insert into Te' at line 2'.
Can anyone help me to get it done? I am not sure where I am wrong.
Thank you in advance.