Return Value
true if there are more result sets; otherwise, false.
By default, the MySqlDataReader is positioned on the first result.
You can determine what result is current using CurrentResult property. Total amount of results stored in MySqlDataReader is represented by ResultCount property.
public void FetchResults(MySqlConnection myConnection) { MySqlCommand cmd = new MySqlCommand("SELECT EmpNo, EName FROM Test.Emp;SELECT * FROM Test.Dept"); cmd.FetchAll = true; cmd.Connection = myConnection; myConnection.Open(); try { MySqlDataReader reader = cmd.ExecuteReader(); Console.WriteLine("Quantity of results: " + reader.ResultCount); while (true) { Console.WriteLine("---------------Result number " + reader.CurrentResult); while (reader.Read()) { Console.Write(reader.CurrentRecord); Console.Write("\t"+reader[0]); Console.WriteLine("\t"+reader[1]); } if (!reader.NextResult()) { break; } Console.ReadLine(); } } finally { myConnection.Close(); } }
Public Sub FetchResults(ByVal myConnection As MySqlConnection) Dim cmd As MySqlCommand = New MySqlCommand("SELECT EmpNo, EName FROM Test.Emp;SELECT * FROM Test.Dept") cmd.FetchAll = True cmd.Connection = myConnection myConnection.Open() Try Dim reader As MySqlDataReader = cmd.ExecuteReader() Console.WriteLine(String.concat("Quantity of results: ", reader.ResultCount)) While True Console.WriteLine(String.Concat("---------------Result number ", reader.CurrentResult)) While reader.Read() Console.Write(reader.CurrentRecord) Console.Write(String.Concat(" ", reader(0))) Console.WriteLine(String.Concat(" ", reader(1))) End While If Not reader.NextResult() Then Exit While End If Console.ReadLine() End While Finally myConnection.Close() End Try End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2