Sivakesh is absolutely wrong. u can very well provide data reader as datasource. only thing is that u cannot do sorting and paging(paging can be done , but with difficulty)
Above answer was rated as good by the following members: dainy_patel
Dim dTable AS new DataTable Dim qry AS String SELECT ItemNo ItemName ItemDescription FROM tblItem Dim sqlCommand AS new SqlCommand(qry sqlConn) sqlConn.Open ResultGrid.DataSource sqlCommand.ExecuteReader() ResultGrid.DataBind() sqlConn.Close
Sivakesh is absolutely wrong. u can very well provide data reader as datasource. only thing is that u cannot do sorting and paging(paging can be done but with difficulty)
We can bind datagrid to datareader.Sorting and paging also possible since we can able to sort the grid itself with out need of dataset or dataview.The only disadvantage is that it overcome the disconnected dataset concept when we using datareader.
Dim connString As String Server localhost;Database Northwind;Integrated Security SSPI Dim sql As String SELECT * FROM Products
Dim conn As SqlConnection New SqlConnection(connString) Dim command As SqlCommand New SqlCommand(sql conn)
Try conn.Open() Dim reader As SqlDataReader command.ExecuteReader() Me.DataGrid1.DataSource reader Me.DataGrid1.DataBind() Catch ex As Exception ' Exception handling code goes here Finally conn.Close() End Try