// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Data; using MySql.Data.MySqlClient; public class MainClass { public static void Main(string[] args) { MySqlConnection con = new MySqlConnection("Database=Test;Data Source=localhost;User Id=;Password="); con.Open(); MySqlCommand sel = new MySqlCommand("SELECT * FROM T1", con); MySqlDataReader rdr = sel.ExecuteReader(); while(rdr.Read()) { int f1 = (int)rdr[0]; //string f2 = (string)rdr[1]; string f2 = rdr[1] as string ?? "(missing)"; Console.WriteLine(f1 + " " + f2); } rdr.Close(); con.Close(); } }