[Mono-list] Simple MySql Connection Problem

Chris Tulabut soul_aspect at yahoo.com
Tue Jul 14 22:14:05 EDT 2009


hi,
im developing a c# console app that will connect to a mysql database locally
and plan on using it on a linux machine.

here's my test code:

using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;

namespace TestDBConnect
{
    class Program
    {
       
        static void Main(string[] args)
        {
             string ConnectionString = "Server=localhost;" +
"Database=myDatabas;" + "User ID=username;" + "Password=myPassword;" +
"Pooling=false;";
             try
             {
                MySqlConnection conn = new
MySqlConnection(ConnectionString);
                conn.Open();

                Console.WriteLine(conn.ServerVersion);
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {

                switch (ex.Number)
                {
                    case 0:
                        Console.WriteLine(DateTime.Now + " >> " + "Cannot
connect to database server.");
                        break;
                    case 1045:
                        Console.WriteLine(DateTime.Now + " >> " + "Invalid
username/password, please try again");
                        break;
                    default:
                        Console.WriteLine(ex.Message);
                        break;
                }
            }
           
          
        }
    }
}


i compile the code:
gmcs program.cs -r:mysql.data.dll

i try a test run
program.exe <----- works fine

mono program.exe <-----------unable to connect to the specified mysql hosts

ive tried Mysql.data.dll connector version 6.1 and 5.2 both with the same
error
mysql.data.dll version 1.0.7 enters Case 0 on my Switch statement and then
throws "unable to connect to the specified mysql hosts"
im using MS VS 2005
windows vista

please help, im really stumped.

-- 
View this message in context: http://www.nabble.com/Simple-MySql-Connection-Problem-tp24490824p24490824.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list