Page 1 of 1

Does mySQLDirect.net support the "SHOW databases" command?

Posted: Mon 28 Feb 2005 07:44
by Micheal
I uses mySQLDirect.net to try the embedded MySQL server. But when the following segment is executed:
CoreLab.MySql.MySqlConnect connect = new CoreLab.MySql.MySqlConnect();
connect.embdded = true;
String sql = "SHOW databases";
CoreLab.MySql.MySqlCommand command = new MySqlCommand(sql, connect);
CoreLab.MySql.DataReader reader = command.executeQuery();

the NotSupportedException rises. And when sql = "SHOW tables", the same exception occurs. The version of libmysqld.dll is 4.1.10. Who can tell me what is teh reason?

Thanks.

Posted: Mon 28 Feb 2005 08:37
by Correct
Sorry.
The statement
"CoreLab.MySql.DataReader reader = command.executeQuery();" is not correct. Its correct form is "CoreLba.MySql.DataReader reader = command.executeReader();"

Posted: Mon 28 Feb 2005 11:22
by Serious
Your code contains a lot of errors. Try this code.

Code: Select all

using System;
using CoreLab.MySql;

namespace Console2003_2
{
	class Class1
	{
    [STAThread]
    static void Main(string[] args)
    {
      MySqlConnection connection = new MySqlConnection("host=localhost;database=requests;user id=root;");
      MySqlCommand command = new MySqlCommand("show databases", connection);
      connection.Open();
      try
      {
        MySqlDataReader reader = command.ExecuteReader();
        try
        {
          while (reader.Read())
          {
            Console.WriteLine(reader.GetString(0));
          }
        }
        finally
        {
          reader.Close();
        }
      }
      catch (Exception ex)
      {
        Console.WriteLine(ex.Message);
      }
      finally
      {
        connection.Close();
      }
    }
	}
}
Check if your user has sufficient privileges to to execute SHOW DATABASES command.

Posted: Tue 01 Mar 2005 07:27
by Micheal
Thank for the reply. The code segment you gave is not suitable for the embedded MySQL server.

Posted: Tue 01 Mar 2005 07:38
by Micheal
Thank for the reply.
The code segment is:
using System;
using CoreLab.MySql;

namespace Console2003_2
{
class Class1
{
[STAThread]
static void Main(string[] args)
{

MySqlConnection connection = new MySqlConnection("host=localhost;database=requests;user id=root;embedded=true;");
MySqlCommand command = new MySqlCommand("SHOW tables",connection);
connection.Open();
try
{
MySqlDataReader reader = command.ExecuteReader();
try
{
while (reader.Read())
{
Console.WriteLine(reader.GetString(0));
}
}
finally
{
reader.Close();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
connection.Close();
}
}
}
}
And NotSupportedException still rises.

Posted: Tue 01 Mar 2005 12:40
by Serious
There was an error in my previous topic. Correct connection string:host=localhost;database=requests;user id=root;embedded=true;
Possible problems with embedded server are described in "Using embedded server" article.
If after attentive reading of this article you still cannot work with embedded server, please write a letter to our tecnical support.

Posted: Wed 02 Mar 2005 12:48
by Micheal
Thank for the reply.
The code segment is:

Code: Select all

using System;
using CoreLab.MySql;

namespace Console2003_2 {
  class Class1 {
    [STAThread]
    static void Main(string[] args) {

      MySqlConnection connection = new MySqlConnection("host=localhost;database=requests;user id=root;embedded=true;");
      MySqlCommand command = new MySqlCommand("SHOW tables", connection);
      connection.Open();
      String sql1 = "use mysql";
      MySqlCommand command = new MySqlCommand(sql1, connection);
      command1.executeNonQuery();
      try {
        MySqlDataReader reader = command.ExecuteReader();
        try {
          while (reader.Read()) {
            Console.WriteLine(reader.GetString(0));
          }
        }
        finally {
          reader.Close();
        }
      }
      catch (Exception ex) {
        Console.WriteLine(ex.Message);
      }
      finally {
        connection.Close();
      }
    }
  }
}
And NotSupportedException still rises at line:reader = command.ExecuteReader(). Since command1.executeNonQuery() can be executed successfully, the system configuration and distribution is correct. So I doubt that MySqlDirect.NET do not support the SHOW databases and SHOW tables.

Posted: Wed 02 Mar 2005 13:28
by Serious
Your code had an errors:

Code: Select all

MySqlCommand command = new MySqlCommand("SHOW tables", connection);
connection.Open();
String sql1 = "use mysql";
MySqlCommand command1 = new MySqlCommand(sql1, connection); // you used the same command name
Did you recompiled MySQL Embedded Server as described in "Using embedded server article"? If you have problems with it, send a mail to our tecnical support.

Posted: Wed 02 Mar 2005 23:06
by Micheal
Thanks for the reply.
I had recompiled libmysqld.dll as told in "Using Embedded MySQL Server" article. There is not error in the following code:
MySqlCommand command = new MySqlCommand("SHOW tables", connection);
connection.Open();
String sql1 = "use mysql";
MySqlCommand command1 = new MySqlCommand(sql1, connection); // you used the same command name.
I have sent a email to your technical support, but there is not any reply still.

Posted: Sat 05 Mar 2005 15:35
by Serious
Did our letter help you? If you have questions about the files we have sent you, please put your questions to the forum.

Posted: Tue 08 Mar 2005 01:14
by Micheal
Thanks for your help.

CoreLab.MySql.MySqlException rises at line using(MySqlDataReader reader = command.ExecuteReader()). I use the evaluation verion of MySQLDirect.net.