Created
December 20, 2011 22:46
-
-
Save Prinzhorn/1503660 to your computer and use it in GitHub Desktop.
All you basically need to use MySQL with .NET
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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