'Declaration Public Event FetchFinished As EventHandler
public event EventHandler FetchFinished
'Declaration Public Event FetchFinished As EventHandler
public event EventHandler FetchFinished
static void UseDataTable(DbDataTable myDataTable, DbConnection myConnection) { myDataTable.Connection = myConnection; myDataTable.SelectCommand = myConnection.CreateCommand(); myDataTable.SelectCommand.CommandText = "SELECT * FROM Dept"; myDataTable.RowFetched += new EventHandler(myDataTable_RowFetched); myDataTable.FetchFinished += new EventHandler(myDataTable_FetchFinished); myDataTable.Open(); } static void myDataTable_RowFetched(object sender, EventArgs e) { Console.Write(string.Format("{0} rows are fetched", ((DbDataTable)sender).RecordCount)); } static void myDataTable_FetchFinished(object sender, EventArgs e) { Console.Write("All records are fetched"); }
Private Shared Sub UseDataTable(ByVal myDataTable As DbDataTable, ByVal myConnection As DbConnection) myDataTable.Connection = myConnection myDataTable.SelectCommand = myConnection.CreateCommand myDataTable.SelectCommand.CommandText = "SELECT * FROM Dept" AddHandler myDataTable.RowFetched, New EventHandler(AddressOf Form1.myDataTable_RowFetched) AddHandler myDataTable.FetchFinished, New EventHandler(AddressOf Form1.myDataTable_FetchFinished) myDataTable.Open() End Sub Private Shared Sub myDataTable_RowFetched(ByVal sender As Object, ByVal e As EventArgs) Console.Write(String.Format("{0} rows are fetched", DirectCast(sender, DbDataTable).RecordCount)) End Sub Private Shared Sub myDataTable_FetchFinished(ByVal sender As Object, ByVal e As EventArgs) Console.Write("All records are fetched") 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