Query.Prepare - Statement(s) could not be prepared.
Posted: Fri 05 Feb 2010 01:00
Hi, I have a problem with TMSQuery
Example:
CREATE TABLE Test (
ID int NOT NULL PRIMARY KEY,
Data varchar
)
Query.SQL.Text := 'SELECT * FROM Test WHERE ID=:ID and Data=:Data';
Query.Prepare;
//OK
Query.SQL.Text := 'INSERT INTO Test(ID, Data) VALUES(:ID, :Data)';
Query.Prepare;
//ERROR
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EMSError with message 'Statement(s) could not be prepared.
Implicit conversion from data type sql_variant to int is not allowed. Use the CONVERT function to run this query.'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
How do I properly prepare the INSERT, without having to explicitly define the parameters?
Thanks for the reply.
Example:
CREATE TABLE Test (
ID int NOT NULL PRIMARY KEY,
Data varchar
)
Query.SQL.Text := 'SELECT * FROM Test WHERE ID=:ID and Data=:Data';
Query.Prepare;
//OK
Query.SQL.Text := 'INSERT INTO Test(ID, Data) VALUES(:ID, :Data)';
Query.Prepare;
//ERROR
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EMSError with message 'Statement(s) could not be prepared.
Implicit conversion from data type sql_variant to int is not allowed. Use the CONVERT function to run this query.'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
How do I properly prepare the INSERT, without having to explicitly define the parameters?
Thanks for the reply.