473,382 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Best Method For Binding to a Datagrid?

Hey folks,

I'm writing a Windows application which has many forms which have Datagrids
on them to display data. These datagrids will not be editable in anyway.
They are there to just view the results of a query (and perhaps double click
on a row to open a new form). Additionally, the queries will often involve
the use of 5 or more tables.

Because efficiency (both speed and memory) is the primary concern what is
the best method to bind to the datagrid?

Coming from a C# asp.net background, I was surprised to see that it appears
you can't bind a SqlDataReader to the datagrid. All examples I've seen
involve using a DataSet and a SqlDataAdapter. Is that really the only and
best way? What other effecient solutions are there? (forward-only
solutions are fine)

Thanks!
Nov 16 '05 #1
2 1689
That's correct, you can't bind ot a reader. If you're going to use the
DataBindings, there's not a whole lot you can do to affect the efficiency
AFAIK. Loading Lookup tables for instance in a background thread when the
app starts, holding them in a static property and not reloading them each
time you need to populate a control will increase the speed b/c you won't
have to keep making trips to the db each time you open an instance of the
same form - but this doesn't affect the bindings per se.

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"John Smith" <js@no.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hey folks,

I'm writing a Windows application which has many forms which have Datagrids on them to display data. These datagrids will not be editable in anyway.
They are there to just view the results of a query (and perhaps double click on a row to open a new form). Additionally, the queries will often involve the use of 5 or more tables.

Because efficiency (both speed and memory) is the primary concern what is
the best method to bind to the datagrid?

Coming from a C# asp.net background, I was surprised to see that it appears you can't bind a SqlDataReader to the datagrid. All examples I've seen
involve using a DataSet and a SqlDataAdapter. Is that really the only and
best way? What other effecient solutions are there? (forward-only
solutions are fine)

Thanks!

Nov 16 '05 #2
> That's correct, you can't bind ot a reader. If you're going to use the
DataBindings, there's not a whole lot you can do to affect the efficiency
Would I be better off not using databindings and populating the datagrid by
looping through a datareader and adding to it a row at a time? Or is there
another non-databinding alternative solution I should consider?

AFAIK. Loading Lookup tables for instance in a background thread when the
app starts,
I need the data to be real time. Thanks though.
holding them in a static property and not reloading them each
time you need to populate a control will increase the speed b/c you won't
have to keep making trips to the db each time you open an instance of the
same form - but this doesn't affect the bindings per se.

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"John Smith" <js@no.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hey folks,

I'm writing a Windows application which has many forms which have

Datagrids
on them to display data. These datagrids will not be editable in anyway. They are there to just view the results of a query (and perhaps double

click
on a row to open a new form). Additionally, the queries will often

involve
the use of 5 or more tables.

Because efficiency (both speed and memory) is the primary concern what is the best method to bind to the datagrid?

Coming from a C# asp.net background, I was surprised to see that it

appears
you can't bind a SqlDataReader to the datagrid. All examples I've seen
involve using a DataSet and a SqlDataAdapter. Is that really the only and best way? What other effecient solutions are there? (forward-only
solutions are fine)

Thanks!


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
4
by: AMeador | last post by:
I have a form that should come up blank (no data in the text boxes, etc...). I want the user to be able to fill in the contols on the form and then save the data to a SQL Server database. My plan...
0
by: Johann Blake | last post by:
I have a form with textboxes that are bound to a dataset. The dataset contains two tables and some of the textboxes use data from one table while other textboxes use data from the other table. I...
4
by: Greg Linwood | last post by:
I am wondering what the best approach to binding XML data to an asp:Table from the Page_Load event in a code behind module? I'm using VB.Net and initially approached this by adding a table to the...
3
by: WebMatrix | last post by:
I am struggling with implementing somewhat complicated UI web-control. I explored Repeater, but I am not sure if it's the best way to go. I am leaning towards writing my own custom control and...
8
by: Richard L Rosenheim | last post by:
I have a dataset containing a parent table related to a child table. The child table contains an ID field (which is configured as autonumber in the datatable), the ID of the parent, plus some...
5
by: Brad Shook | last post by:
I am trying to bind one column of a datagrid to a seperate textbox and the rest of the fields to a datagrid. the comments are too large to fit in a datagrid so I created a textbox below the...
12
by: Aaron Smith | last post by:
What is the best way to handle data in a multiple user environment? We have forms that will allow users to add edit and delete data from a table on SQL server. The data could be edited on multiple...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.