473,387 Members | 1,844 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,387 software developers and data experts.

Bind datareader to datagrid



Hi...

My program make a select to an table and return the results to a
datagrid, it's all ok with dataset, but in large tables it needs to get
the entire table to show in datagrid and sometimes it takes much time...

So I thik of use the datareader, but how can I bind the data that it is
picking from the database to the datagrid???

thx...

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
6 5046
Hi,

Using the same way:

SqlDataReader reader = GetReader();
datagrid.DataSource = reader;
datagrid.DataBind();
reader.Close();

Note that you NEED to close the datareader !!! , otherwise you could let the
connection open.

Have you considered pagination?
cheers,
"Ricardo Luceac" <rl*****@gmail.com> wrote in message
news:OM**************@TK2MSFTNGP15.phx.gbl...


Hi...

My program make a select to an table and return the results to a
datagrid, it's all ok with dataset, but in large tables it needs to get
the entire table to show in datagrid and sometimes it takes much time...

So I thik of use the datareader, but how can I bind the data that it is
picking from the database to the datagrid???

thx...

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #2
Hi,

Using the same way:

SqlDataReader reader = GetReader();
datagrid.DataSource = reader;
datagrid.DataBind();
reader.Close();

Note that you NEED to close the datareader !!! , otherwise you could let the
connection open.

Have you considered pagination?
cheers,
"Ricardo Luceac" <rl*****@gmail.com> wrote in message
news:OM**************@TK2MSFTNGP15.phx.gbl...


Hi...

My program make a select to an table and return the results to a
datagrid, it's all ok with dataset, but in large tables it needs to get
the entire table to show in datagrid and sometimes it takes much time...

So I thik of use the datareader, but how can I bind the data that it is
picking from the database to the datagrid???

thx...

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #3


Sory but what is that GetReader()???

What is Pagination...

see ya...

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #4


Sory but what is that GetReader()???

What is Pagination...

see ya...

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #5

"Ricardo Luceac" <rl*****@gmail.com> wrote in message
news:Oc**************@TK2MSFTNGP10.phx.gbl...


Sory but what is that GetReader()???
That is any method that you use to get a DataReader, you hvae to change it
to reflect the name you used.
What is Pagination...
Is how you display a large table, you show only X records and use some way
to go a Next and/or Prev

cheers,

see ya...

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #6

"Ricardo Luceac" <rl*****@gmail.com> wrote in message
news:Oc**************@TK2MSFTNGP10.phx.gbl...


Sory but what is that GetReader()???
That is any method that you use to get a DataReader, you hvae to change it
to reflect the name you used.
What is Pagination...
Is how you display a large table, you show only X records and use some way
to go a Next and/or Prev

cheers,

see ya...

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #7

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

Similar topics

1
by: Al | last post by:
in order to implement sorting, paging in a datagrid, can I have the datasource of the datagrid a datareader or it must be a dataset then I create a dataview and make it a datasource of the...
0
by: Ricardo Luceac | last post by:
Hi... My program make a select to an table and return the results to a datagrid, it's all ok with dataset, but in large tables it needs to get the entire table to show in datagrid and sometimes...
2
by: timmso | last post by:
I got this sample of code from Mike Moore in response to my question of how I create clickable links from a data source. <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate>...
3
by: AFN | last post by:
I need to manually create the data to be shown in a datagrid (or some data table object). Should I create an array and bind the array to the datagrid OR should I create a temporary dataset and...
7
by: Bart Schelkens | last post by:
Hi, I have 2 more questions : 1. Can I fill a datagrid by using a DataReader or does it have to be a DataSet or a DataView? 2. In my datagrid I need to display two images and one of does...
4
by: Shapper | last post by:
Hello, I have this code to bind a DataGrid to a DataReader when page loads: Sub Page_Load(Sender As Object, e As EventArgs) dgContent.DataSource = drContent dgContent.DataBind() End Sub ...
1
by: Fred Flintstone | last post by:
Just new to .net, and started using oledb connection to database. After getting most things working, now want to bind to a datagrid, but have not been successful as of yet. Will use alternate db...
1
by: Niclas | last post by:
Hi, I am using a SQL query that uses a CURSOR to loop and executes a SELECT statement in each loop. When I bind a datagrid to this stored procedure through a datareader as data source, I only...
0
by: pbd22 | last post by:
Hi. I am returning to an old bit of code in our program and need to figure out how to sort my columns on bind. I am sorting on Date (mostly) and some other values. Problem is, the code is an...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.