MySqlCommandExecuteReader Method |
Namespace: MySql.Data.MySqlClient
When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. The command executes this stored procedure when you call ExecuteReader.
While the MySqlDataReader is in use, the associated MySqlConnection is busy serving the MySqlDataReader. While in this state, no other operations can be performed on the MySqlConnection other than closing it. This is the case until the Close method of the MySqlDataReader is called.
public void CreateMySqlDataReader(string mySelectQuery, MySqlConnection myConnection) { MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection); myConnection.Open(); MMySqlDataReader myReader; myReader = myCommand.ExecuteReader(); try { while(myReader.Read()) { Console.WriteLine(myReader.GetString(0)); } } finally { myReader.Close(); myConnection.Close(); } }