[Mono-list] MySql on mono
Arx Henrique
arxcruz@yahoo.com.br
Thu, 29 Jul 2004 13:39:39 -0300
--=-z95k5aHrIaQTLUYzg1sW
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi all,
i'm a newbie in mono and i'm from brazil, so my english is very bad :)
i try make a mysql connection with mono like i see in monodoc, but when
i will run the application this erros are reported:
Unhandled Exception: ByteFX.Data.MySqlClient.MySqlException: Unable to
connect to any of the specified MySQL hosts
in <0x00158> ByteFX.Data.MySqlClient.Driver:Open (ByteFX.Data.
MySqlClient.MySqlConnectionString)
in <0x0003c> ByteFX.Data.MySqlClient.MySqlInternalConnection:Open ()
in <0x000ef> ByteFX.Data.MySqlClient.MySqlPool:CreateNewPooledConnection
()
in <0x00214> ByteFX.Data.MySqlClient.MySqlPool:GetPooledConnection ()
in <0x00052> ByteFX.Data.MySqlClient.MySqlPool:GetConnection ()
in <0x00112> ByteFX.Data.MySqlClient.MySqlPoolManager:GetConnection
(ByteFX.Data.MySqlClient.MySqlConnectionString)
in <0x0007c> ByteFX.Data.MySqlClient.MySqlConnection:Open ()
But, i can connect to mysql database with others applications like php
and mysql control center. I don't know what's happen.
can anybody help me ?
the source code of my app is attached
--=-z95k5aHrIaQTLUYzg1sW
Content-Disposition: attachment; filename=main.cs
Content-Type: text/x-csharp; name=main.cs; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
// created on 28/7/2004 at 13:57
using System;
using System.Data;
using ByteFX.Data.MySqlClient;
public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Server=localhost;" +
"Database=cientifico;" +
"User ID=root;";
MySqlConnection dbcon;
dbcon = new MySqlConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
// requires a table to be created named employee
// with columns firstname and lastname
// such as,
// CREATE TABLE employee (
// firstname varchar(32),
// lastname varchar(32));
string sql = "select nom_doenca from doencas";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string FirstName = (string) reader["nom_doenca"];
Console.WriteLine("Name: " + FirstName);
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}
--=-z95k5aHrIaQTLUYzg1sW--