Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Tutorial2
- {
- public static void Main()
- {
- string connStr = "server=localhost;user=root;database=world;port=3306;password=******;";
- MySqlConnection conn = new MySqlConnection(connStr);
- try
- {
- Console.WriteLine("Connecting to MySQL...");
- conn.Open();
- string sql = "SELECT Name, HeadOfState FROM Country WHERE Continent='Oceania'";
- MySqlCommand cmd = new MySqlCommand(sql, conn);
- MySqlDataReader rdr = cmd.ExecuteReader();
- while (rdr.Read())
- {
- Console.WriteLine(rdr[0]+" -- "+rdr[1]);
- }
- rdr.Close();
- conn.Close();
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.ToString());
- }
- Console.WriteLine("Done.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement