Simple Database Access


string connectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=test;USER=root;PASSWORD=mypassword;OPTION=3;";
IDbConnection conn = new OdbcConnection(connectionString);
conn.Open();
IDbCommand command = new OdbcCommand("select UserID, FirstName from Users");
command.Connection = conn;
IDataReader reader = command.ExecuteReader();
while (reader.Read())
{
	string userID = (string) reader["UserID"];
	string firstName = (string) reader["FirstName"];
	Console.WriteLine("@@");
}
conn.Close();

You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

AddThis Social Bookmark Button

Similar Posts

Comments are closed.