Page 1 of 1
Query empty message
Posted: Sun 07 Aug 2005 20:50
by Guest
When i am trying to execute a sql with MyCommand i get a error
Query was empty. But i can´t find any query in the MyCommand
Code: Select all
MySQLModule->MyCommand->SQL->Clear();
MySQLModule->MyCommand->SQL->Assign("use tempDB");
MySQLModule->MyCommand->Execute(1);
Re: Query empty message
Posted: Sun 07 Aug 2005 20:51
by Guest
Anonymous wrote:When i am trying to execute a sql with MyCommand i get a error
Query was empty. But i can´t find any query in the MyCommand
Code: Select all
MySQLModule->MyCommand->SQL->Clear();
MySQLModule->MyCommand->SQL->Assign("use tempDB;");
MySQLModule->MyCommand->Execute(1);
Posted: Mon 08 Aug 2005 07:33
by Paul
We cannot compile your example. Possibly you whanted to write
MySQLModule->MyCommand->SQL->Text = "use tempDB;";
This example works without errors
Posted: Mon 08 Aug 2005 08:53
by mikrodidakt
I am the gaust above i just forgotte to log in
sorry to bother u but i dont get it.
Code: Select all
AnsiString sqlStr = "CREATE database IF NOT EXISTS mandoMySQL;\n";
sqlStr += "USE mandoMySQL;";
MySQLModule->MyCommand->SQL->Clear();
MySQLModule->MyCommand->SQL->Text = sqlStr;
MySQLModule->MyCommand->Execute(1);
then i get a EMySQLException with the message
You have a error in your SQL syntax; check the manula that corresponds to your MySQL server version for the right syntax to use near;
USE mandoMySQL at line 1. Process stopped.
I have rune the sql with the server and it works
I have tried to put it in the string list editor for the MyCommand and then run it but it gave the same message.
Posted: Mon 08 Aug 2005 09:03
by mikrodidakt
it works if i separate them
Code: Select all
AnsiString sqlStr1 = "CREATE database IF NOT EXISTS mandoMySQL;";
MySQLModule->MyCommand->SQL->Clear();
MySQLModule->MyCommand->SQL->Text = sqlStr1;
MySQLModule->MyCommand->Execute(1);
AnsiString sqlStr2 = "use mandoMySQL;";
MySQLModule->MyCommand->SQL->Clear();
MySQLModule->MyCommand->SQL->Text = sqlStr2;
MySQLModule->MyCommand->Execute(1);
but should it not be possible to execute two sql statments, as it is with the
server where i can write:
create databse IF NOT EXISTS mandoMySQL; use mandoMySQL;
Thanks for the help any way i am very happy with MyDAC it is easy compared to other components that i have used.
Posted: Mon 08 Aug 2005 09:08
by GEswin
Use TMyScript to execute more than one statment at once.
Posted: Mon 08 Aug 2005 09:34
by Paul
You must use TMScript component for compound queries.
Posted: Mon 08 Aug 2005 09:49
by mikrodidakt
thank u