[Mono-devel-list] MySQL problem

Paul paul at all-the-johnsons.co.uk
Sun Feb 27 11:28:32 EST 2005


I've used the MySQL snippet on the mono-project website to access an SQL
database that I have set up.

The code looks like this (so you don't need to find it!)

using System;
using System.Data;
using ByteFX.Data.MySqlClient;

public class Test
  public static void Main(string[] args)
    string connectionString = "Server=localhost;" + "Database=employee;"
      "User ID=paul;" + "Password=password";
    IDbConnection dbcon;
    dbcon = new MySqlConnection(connectionString);
    IDbCommand dbcmd = dbcon.CreateCommand();
    string sql = "SELECT firstname, lastname " + "FROM employee";
    dbcmd.CommandText = sql;
    IDataReader reader = dbcmd.ExecuteReader();
      string FirstName = (string) reader["firstname"];
      string LastName = (string) reader["lastname"];
      Console.WriteLine("Name: " + FirstName + " " + LastName);

    reader = null;
    dbcmd = null;
    dbcon = null;

This compiles fine, but when I run it, I get the following

Unhandled Exception: ByteFX.Data.MySqlClient.MySqlException: #HY000Host
'localhost.localdomain' is not allowed to connect to this MySQL server
in <0x000b0> ByteFX.Data.MySqlClient.Driver:ReadPacket ()
in <0x00134> ByteFX.Data.MySqlClient.Driver:Open
(ByteFX.Data.MySqlClient.MySqlConnectionString settings)
in <0x00039> ByteFX.Data.MySqlClient.MySqlInternalConnection:Open ()
in <0x000b1> ByteFX.Data.MySqlClient.MySqlPool:CreateNewPooledConnection
in <0x0018a> ByteFX.Data.MySqlClient.MySqlPool:GetPooledConnection ()
in <0x00042> ByteFX.Data.MySqlClient.MySqlPool:GetConnection ()
in <0x000cf> ByteFX.Data.MySqlClient.MySqlPoolManager:GetConnection
(ByteFX.Data.MySqlClient.MySqlConnectionString settings)
in <0x0004b> ByteFX.Data.MySqlClient.MySqlConnection:Open ()

Now, I have a similar program in C which works fine. Is there some
difference between accessing something in C# than in C? I've seen this
error before, but only when messing about with mysqladmin



"I like blinking me" - Helen, Big Brother 2 contestant
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050227/7b93fdd2/attachment.bin 

More information about the Mono-devel-list mailing list