Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.Net DataGrid From DataReader?

Status
Not open for further replies.

SSchimsky

MIS
Mar 26, 2002
16
0
0
US
Hi,

Is it possible to set the DataSource of a VB.NET DataGrid to a DataReader rather than a DataSet Table? If So, How?

Thanks for any info.

Steve
 

Dont think you can, I have tried and it didnt like it.

It gave an error of:


An unhandled exception of type 'System.Exception' occurred in system.windows.forms.dll

Additional information: Complex DataBinding accepts as a data source either an IList or an IListSource

 
I'm not an expert, but my understanding is that you want to pass the entire data set to the grid control at once.

If I understand how the Data Reader works, it needs to be hit again and again, dispensing one record at a time until it has cycled through the data. This won't work with a grid control. (I'm tying to find out more about the Data Reader myself today).

Try creating a dataset instead and binding that to the grid, I think you'll have better luck.

Craig in NJ
 
Nope.....you can't do it in a windows form but you can in a web app. Not sure why but that's just the way it is.



'aspx sample
Me.DataGrid1.DataSource = sqlcmd.ExecuteReader
Me.DataGrid1.DataBind

Scott
Programmer Analyst
<{{><
 

Just what I thought. :-(

Thanks for all your help!

Steve
 
its prolly a waste of time but check out planetsourcecode.com or other sites.....maybe someone created a control that inherits the datagrid with the functionality you're requesting. I saw an article on databinding a listview but it wasn't really straight forward.

Best Wishes.

Scott
Programmer Analyst
<{{><
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top