?
Solved

SQL Query

Posted on 2005-04-26
5
Medium Priority
?
213 Views
Last Modified: 2010-04-23
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
Comment
Question by:SETP
  • 3
  • 2
5 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1000 total points
ID: 13866118
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
 
LVL 18

Assisted Solution

by:tusharashah
tusharashah earned 1000 total points
ID: 13866206
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13866228
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
 
LVL 18

Expert Comment

by:tusharashah
ID: 13866285
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13866326
And, light-weight, too :)  Less overhead, and faster, but not as much functionality.

Bob
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question