Query empty message

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Guest

Query empty message

Post by Guest » Sun 07 Aug 2005 20:50

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);

Guest

Re: Query empty message

Post by Guest » Sun 07 Aug 2005 20:51

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);

Paul
Posts: 725
Joined: Thu 28 Oct 2004 14:06

Post by Paul » Mon 08 Aug 2005 07:33

We cannot compile your example. Possibly you whanted to write
MySQLModule->MyCommand->SQL->Text = "use tempDB;";
This example works without errors

mikrodidakt
Posts: 20
Joined: Fri 05 Aug 2005 12:20
Location: Sweden

Post by mikrodidakt » Mon 08 Aug 2005 08:53

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.
Last edited by mikrodidakt on Mon 08 Aug 2005 09:04, edited 2 times in total.

mikrodidakt
Posts: 20
Joined: Fri 05 Aug 2005 12:20
Location: Sweden

Post by mikrodidakt » Mon 08 Aug 2005 09:03

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.

GEswin
Posts: 186
Joined: Wed 03 Nov 2004 16:57
Location: Spain
Contact:

Post by GEswin » Mon 08 Aug 2005 09:08

Use TMyScript to execute more than one statment at once.

Paul
Posts: 725
Joined: Thu 28 Oct 2004 14:06

Post by Paul » Mon 08 Aug 2005 09:34

You must use TMScript component for compound queries.

mikrodidakt
Posts: 20
Joined: Fri 05 Aug 2005 12:20
Location: Sweden

Post by mikrodidakt » Mon 08 Aug 2005 09:49

thank u

Post Reply