Skip to content

Instantly share code, notes, and snippets.

@Prinzhorn
Created December 20, 2011 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Prinzhorn/1503660 to your computer and use it in GitHub Desktop.
Save Prinzhorn/1503660 to your computer and use it in GitHub Desktop.
All you basically need to use MySQL with .NET
using (MySqlDataReader reader = MySqlHelper.ExecuteReader(
"CONNECTION STRING",
"SELECT * FROM my_table WHERE foo=?bar;",
new MySqlParameter("?bar", 1337)/*, more params if needed */)
{
if(!reader.hasRows)
{
//No data
return;
}
while(reader.Read())
{
reader.getInt(0);
reader.getString(1);
//etc.
}
//If more than one query/select (semicolon separated)
reader.NextResult();
//while(reader.Read())
//like above
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment