binding a datareader to a grid

soad524

New Member
I know that you can bind a dataset to a datagrid, but I hoping to accomplish the same functionality with a datareader (it is after all a forward only application)<BR><BR>thanks in advance,<BR>JoelI don't have the .NET runtime installed on my PC here at work, but, have you tried something like....<BR><BR> Dim objCnn As New SQLConnection(strConn)<BR> Dim objCmd As New SQLCommand(strCmd, objCnn)<BR> Dim objDR As SQLDataReader = Nothing<BR> objCmd.ActiveConnection.Open()<BR> objCmd.Execute(objDR)<BR><BR> DataGrid.DataSource = objDR<BR> DataGrid.DataBind<BR><BR>According to the QuickStart docs...<BR><BR> "controls can bind only to collections that <BR> "support the ICollection interface"<BR><BR>... although I'm not sure that the DBDataReader Class (which is implemented by both SQLDataReader and ADODataReader)implements the ICollection interface.<BR><BR>Here is where I looked (watch out for wrapping)...<BR><BR> http://msdn.microsoft.com/library/dotnet/cpref/frlrfsystemcollectionsicollectionclasstopic.htm<BR><BR><BR>HTH<BR><BR>Darren<BR>[ [email protected] ]<BR><BR>
 
Back
Top