New to Telerik UI for WinForms? Download free 30-day trial

Binding to DataReader

To extract values from a data source using a DataReader, use the GridViewTemplate LoadFrom() method to consume an object instance that supports IDataReader. The code sample below uses a OleDbDataReader reading an Access data source:

OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\DataSources\\Nwind.mdb");
OleDbCommand cmd = new OleDbCommand("Select TOP 5 * FROM Customers", conn);
OleDbDataReader reader = cmd.ExecuteReader();

Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\DataSources\\Nwind.mdb")
Dim cmd As New OleDbCommand("Select TOP 5 * FROM Customers", conn)
Dim reader As OleDbDataReader = cmd.ExecuteReader()

See Also

In this article