Hi ,
I'm confused on dataset/datatable updating to datasource.
According to one view, mass updating of datasource with datatable.rowstatechanges thru
dataadapter is not professional and not to be used in real production
environment.
On the other hand, a lot of sources in internet and else talks about how
to use dataadapter/command builder/mass update/insert/delete .Almost all of
the datagridview operations are explained with dataadapter/dataset/datatable and
adapter.Update(dataset) style

I like to have opinion on this so that I can set my approach.

I can populate a gridview with dataadapter.Fill method O.K. no problem. But on updating the cells, inserting new data into cells (I don't mean creating new physical row) , and somehow deciding the rowstates without being dependent on dataset /datatable rowstateschange facility so that I can do that independently.

I like to be clarified on these issues with your help.

Thanks in advance,

snky

when i began to .NET, i used to have the same problem you had.
It is not that confusing in fact. If you are developing web application, you almost never use batch update because all the operation takes place in IIS server anyway. If you have a desktop application batch update becomes useful. Basically you make a copy of database table to datatable object or a dataset object in case you have related tables, then you make the changes and when you finish you commit the changes to the database, when you use update method of DataAdapter, it just checks the flags in the rows and use its sql statements accordingly.
If you are going to use batch updates, you always need to handle concurrency conflicts. Since more than one people work on the same datatable in disconnected manner, one might delete the record which the other is modifying, so when they commit the changes to the server, server generates concurrency conflict exception which needs to be handled.

I'm not sure on what your question is but the .NET DataSet is tested, tried and true. It will work and let the DataSet worry how it handles the RowStatus because that is internal to its workings really.

I personally do not advocate or use a DataSet but for other reasons. My reasons are that it tries to do too much and lost functionality because of it. It does what it was intended to do very well.

>I personally do not advocate or use a DataSet but for other reasons. My reasons are that it tries to do too much and lost functionality because of it. It does what it was intended to do very well.

Dejavu :)

Thank you all,

First of all, it’s a desktop Windows Form environment.

Secondly my I assume that you mean disconnected fashion by “batch updating”.

Thirdly with “Basically you make a copy of database table to datatable object or a dataset object in case you have related tables,” do you mean joint database table . If so what if you don’t have joint tables and just a single table ?

With “batch” do you mean, instead of dataadapter updating, you loop thru the dataset (or maybe grid) and make individual insert/update/delete to database based on the flags of database/datatable and there handle the concurrency.

To elaborate further let me explain how I have been doing similar operation with the development tools I’m currenty using. This is the scenario;

When I populate the dataGridView control on the form ( we call it table) I mark the row header that this is a new row, whatever I key in is considered to be a new data and if executed will be an Insert operation. So this is not necessarily a new row in the grid. I decide whether this is a new data or editing previously created data or deleting. So it is my decision how I mark the row. How I update the database is another issue. I can do it batch or otherwise.

So actually my current tools are behaving differently than .Net , this is why I need an experienced navigation for my positioning because I don’t want to lose time since I’m trying to migrate to c# environment. I hope I did not make it more complicated.

By the way,"I personally do not advocate ", what would you advocate in a nutshell?

snky

DataTable, SqlCommand, SqlConnection, SqlDataReader. Much the same technology as the DataSet uses under the hood -- you just have to implement it yourself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.