rendered paste body using System;
using System.Data;
// using MySql.Data.MySqlClient;
using ByteFX.Data.MySqlClient;
public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Server=10.0.0.67;" +
"Database=test;" +
"User ID=test;" +
// "Password=test;" +
"Pooling=false";
IDbConnection 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 firstname, lastname " +
"FROM employee";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string FirstName = (string) reader["firstname"];
string LastName = (string) reader["lastname"];
Console.WriteLine("Name: " +
FirstName + " " + LastName);
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}
[killfill@delly ~/Desktop]$ mono mysql.exe
Unhandled Exception: ByteFX.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts ---> System.Net.Sockets.SocketException: No such host is known
at System.Net.Dns.hostent_to_IPHostEntry (System.String h_name, System.String[] h_aliases, System.String[] h_addrlist) [0x00000]
at System.Net.Dns.GetHostByName (System.String hostName) [0x00000]
at ByteFX.Data.Common.StreamCreator.GetStream (Int32 timeOut) [0x00000]
at ByteFX.Data.MySqlClient.Driver.Open (ByteFX.Data.MySqlClient.MySqlConnectionString settings) [0x00000] --- End of inner exception stack trace ---
at ByteFX.Data.MySqlClient.Driver.Open (ByteFX.Data.MySqlClient.MySqlConnectionString settings) [0x00000]
at ByteFX.Data.MySqlClient.MySqlInternalConnection.Open () [0x00000]
at ByteFX.Data.MySqlClient.MySqlConnection.Open () [0x00000]
[killfill@delly ~/Desktop]$ ping 10.0.0.67
PING 10.0.0.67 (10.0.0.67): 56 data bytes
64 bytes from 10.0.0.67: icmp_seq=0 ttl=64 time=0.161 ms