Skip to content

Instantly share code, notes, and snippets.

@nicolas-martin
Created April 2, 2015 18:57
Show Gist options
  • Save nicolas-martin/5f9c9cc7d8609c74369d to your computer and use it in GitHub Desktop.
Save nicolas-martin/5f9c9cc7d8609c74369d to your computer and use it in GitHub Desktop.
using (var connection = new MySqlConnection("Server=localhost;Database=MyDatabaseName;Uid=root;Pwd=;"))
using (var command = connection.CreateCommand()) {
connection.Open();
command.CommandText = "select id, name from widgets";
using (var reader = command.ExecuteReader())
while (reader.Read())
Console.WriteLine(reader.GetString(0) + ": " + reader.GetString(1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment