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

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

Postby Micheal » Mon 28 Feb 2005 07:44

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.
Micheal
 

Postby Correct » Mon 28 Feb 2005 08:37

Sorry.
The statement
"CoreLab.MySql.DataReader reader = command.executeQuery();" is not correct. Its correct form is "CoreLba.MySql.DataReader reader = command.executeReader();"
Correct
 

Postby Serious » Mon 28 Feb 2005 11:22

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.
Serious
 

Postby Micheal » Tue 01 Mar 2005 07:27

Thank for the reply. The code segment you gave is not suitable for the embedded MySQL server.
Micheal
 

Postby Micheal » Tue 01 Mar 2005 07:38

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.
Micheal
 

Postby Serious » Tue 01 Mar 2005 12:40

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.
Serious
 

Postby Micheal » Wed 02 Mar 2005 12:48

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.
Micheal
 

Postby Serious » Wed 02 Mar 2005 13:28

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.
Serious
 

Postby Micheal » Wed 02 Mar 2005 23:06

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.
Micheal
 

Postby Serious » Sat 05 Mar 2005 15:35

Did our letter help you? If you have questions about the files we have sent you, please put your questions to the forum.
Serious
 

Postby Micheal » Tue 08 Mar 2005 01:14

Thanks for your help.

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


Return to dotConnect for MySQL