473,705 Members | 5,438 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

binding datareader to datagrid in C# windows form

Hi,

Is it possible to bind DataReader to a DataGrid in C# windows form? And
how?
And can we update data in a DataSet by using the DataReader?
Thanks for help.
Jason
Nov 17 '05 #1
5 5763
> Is it possible to bind DataReader to a DataGrid in C# windows form?

No you can't directly. Read the data into a DataSet, and bind the grid to
it.
And can we update data in a DataSet by using the DataReader?


No, DataReaders represent a READ ONLY, FORWARD ONLY cursor. Use a
DataAdapter in order to update the data.

Regards - Octavio
Nov 17 '05 #2
Then why do we need a DataReader? Sounds that DataSet can do anything.

"Octavio Hernandez" <do****@danysof t.com> ¼¶¼g©ó¶l¥ó·s»D: eN************* *@TK2MSFTNGP09. phx.gbl...
Is it possible to bind DataReader to a DataGrid in C# windows form?


No you can't directly. Read the data into a DataSet, and bind the grid to
it.
And can we update data in a DataSet by using the DataReader?


No, DataReaders represent a READ ONLY, FORWARD ONLY cursor. Use a
DataAdapter in order to update the data.

Regards - Octavio

Nov 17 '05 #3
Hi Jason,
I don't think it'll be possible.
1) DataReader does not implement any specific interface so that it can
be bindable
2) DataReader is for reading data.So if some how u r able to bind
that,it won't allow u to edit that.So it's of no use.
3) DataReader is forward only,that means u can get a record at a time
but can't traverse back to the prev record.
I think the last (most important one!!)reason would be ---
ADO.NET follows Disconnected Model.But DataReader operates in
connected mode.So there is no scope to retrieve data from data source
and then modify it and save it,in case of DataReader.

If u have such a requirement then use DataSet/Disconeccted model
instead of datareader. :)

From
Arindam
Jason Huang wrote:
Hi,

Is it possible to bind DataReader to a DataGrid in C# windows form? And
how?
And can we update data in a DataSet by using the DataReader?
Thanks for help.
Jason


Nov 17 '05 #4
The DataReader allows us to read rows from a result set and store them in a
DataTable (DataSet).
For instance, the DataAdapter internally uses a DataReader in order to
execute the SELECT statement.

Regards - Octavio

"Jason Huang" <Ja************ @hotmail.com> escribió en el mensaje
news:Ot******** ******@tk2msftn gp13.phx.gbl...
Then why do we need a DataReader? Sounds that DataSet can do anything.

"Octavio Hernandez" <do****@danysof t.com>
¼¶¼g©ó¶l¥ó·s»D: eN************* *@TK2MSFTNGP09. phx.gbl...
Is it possible to bind DataReader to a DataGrid in C# windows form?


No you can't directly. Read the data into a DataSet, and bind the grid to
it.
And can we update data in a DataSet by using the DataReader?


No, DataReaders represent a READ ONLY, FORWARD ONLY cursor. Use a
DataAdapter in order to update the data.

Regards - Octavio


Nov 17 '05 #5
On Fri, 19 Aug 2005 16:54:30 +0800, "Jason Huang"
<Ja************ @hotmail.com> wrote:
Then why do we need a DataReader? Sounds that DataSet can do anything.

Jason,

A DataSet cannot do anything on its own. It merely represent a
disconnected chunk of data with any data updates and, optionally,
validation errors, nothing else. You can use it in a variety of ways,
including data binding.

In general, you'd use a DataReader or DataAdapter to populate a
DataSet, make changes to the data in the DataSet either directly or
thru data binding and then use a DataAdapter to submit your changes to
the database.

The above briefly describes the disconnected nature of ADO.NET: you
can acquire any data in a form of a DataSet, pass it around as much as
you like, within a single application or between many apps, make
changes to it (inserts/updates/deletes), and then hand it back to a
DataAdapter to submit the changes to the underlyng data storage.

"Octavio Hernandez" <do****@danysof t.com> ¼¶¼g©ó¶l¥ó·s»D: eN************* *@TK2MSFTNGP09. phx.gbl...
Is it possible to bind DataReader to a DataGrid in C# windows form?


No you can't directly. Read the data into a DataSet, and bind the grid to
it.
And can we update data in a DataSet by using the DataReader?


No, DataReaders represent a READ ONLY, FORWARD ONLY cursor. Use a
DataAdapter in order to update the data.

Regards - Octavio

Nov 17 '05 #6

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

Similar topics

1
1541
by: Deepa | last post by:
I am doing an ASP.Net application wherein I have a datagrid which I need to populate dynamically. The grid has 5 rows and two columns. In the 2nd col I need to insert dropdown boxes. I'll have to populate both the cols from the database. The values for the 2 cols come from 2 diff tables. How do I do this? Also in the design mode, do I have to manually mention the Collections property of the datagrid columns as Template Columns? This is...
5
2639
by: Jean Carlo | last post by:
Hello guys I`m developing a windows form that contain one Datagrid. In this datagrid I insert a checkBox Column. I need to get all rows where checkbox is checked by user. How do I get this rows ? I can´t use the DataSource of Datagrid because I don´t have a Column source for checkBox in my DataSource. Is there any method in datagrid to loop in datagrid rows ?
2
1466
by: Wayne | last post by:
I have a datagrid on my windows form, it needs to be read only and when a user selects a row, I want the whole row to be selected. How would I go about doing this? -- Thanks Wayne Sepega Jacksonville, Fl
3
2123
by: Nina | last post by:
Hi there, Is there anyone knows how to make windows form datagrid that is bound to an array editable? How to catch when a cell has been edited? Thank you for your help. Nina
1
1582
by: MCDave | last post by:
Hi all, I'm trying to get a datagrid to display a button in every row, so that when the user clicks on it, the value from the first column (record index) is read, and then a new window opens for the user to see the full record (for editing or what not). I've seen examples in ASP.Net all over the place, but none for Windows Forms. Alternatively the user could just click on a row (no button) and the window
0
918
by: Jason Huang | last post by:
Hi, I am wondering binding the DataGrid to a DataSet in the design time or binding later on in the run time. Which one is more ideal? Thanks for help. Jason
4
1753
by: Steven | last post by:
Hi, I have a database table field to store the form name, I want to create the particular windows form by using the value that read from that DB field. For examples, the table field has a value "ThisForm", then I want to create the form with class name "ThisForm" (Suppose I have already defined the class "ThisForm"). Can I do this by using late bindnig? Any source code for reference? Thanks! Steven.
1
2794
by: Rajesh Kumar Choudhary | last post by:
Hi, I want to use the system.windows.form.datagrid control present in .net 2005 or 2003. Is it possible to use this? Please let me know if it is not supported. I have seen and used the classes from FCL using system.tlb or mscorelib.tlb from dot net framework. I could use ArrayList successfully without any issue.
1
2227
by: renuami | last post by:
Hi I am receiving Object reference not set to an instance of an Object when binding Child dataGrid in the ItemCommandEvent of Parent dataGrid. Can someone please guide me what is wrong in the code below? I checked the table size and it is 2. Please advise Thanks
0
8768
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9139
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6606
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5933
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2491
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2083
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.