• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

SQL Query

In VB.NET 2003, I have an OldDbCommand that returns certain records of an Access database table. What is the simplest way of showing this in a DataGrid?

The OleDbCommand can return a a Scalar value which is no good since I am returning a couple of columns.
It can return a DataReader, but I can't bind that to a DataGrid
It can return nothing - again no good.

Is there no way to get it to return a table or an array which can then be bound to the datagrid? Or will I have to use it's Fill method to popualte a DataSet and then bind the DataSet to the DataGrid?

Thanks
0
SETP
Asked:
SETP
  • 3
  • 2
2 Solutions
 
Bob LearnedCommented:
The easiest is what is to use an OleDbDataAdapter, and create a SelectCommand, and then Fill a dataset, and bind that to the DataGrid.

Bob
0
 
tusharashahCommented:
Also, you CAN bind DataReader with DataGrid...

Here's one Example:
 http://authors.aspalliance.com/aspxtreme/shared/viewsrc.aspx?path=/aspxtreme/adonet/demos/binddatareadertodatagrid.aspx.src&file=BindDataReadertoDataGrid.aspx&font=3
[ Click on View Sample on Topy to view workign example ]

-tushar
0
 
Bob LearnedCommented:
While it can work, the DataReader is a forward-only view, and doesn't provide the "best" method of binding to a DataGrid.

Bob
0
 
tusharashahCommented:
Absolutely correct. As DataReader object can't be serialized, you'll have problem if you want to Add Some Inbuilt functionality to DataGrid. But, it's one of the straight fwd and easy way of Populating Grid.

-tushar
0
 
Bob LearnedCommented:
And, light-weight, too :)  Less overhead, and faster, but not as much functionality.

Bob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now