using System;
using System.Data;
using MySql.Data.MySqlClient;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
using (MySqlConnection conn = new MySqlConnection("server=localhost;uid=root;pwd=root123;database=test"))
{
conn.Open();
using (MySqlCommand cmd = new MySqlCommand("select * from Person", conn))
{
MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
Console.WriteLine("{0},{1},{2}", reader["Id"], reader["Name"], reader["Age"]);
}
}
conn.Close();
}
Console.ReadKey();
}
}
}