Update From dataset to Database

B

Baddy2009

Hi everybody,
I have a problem: I have a form and a DataGridView. I used DataAdapter
to get data from the DB. My source Db have two tables, and i use the
join the create e new tables in the dataset, then I load the dataset
into the datagrid. Now to upgrade the database directly from the
DataGrid what i have to do?

Thanks
 
P

Peter Bromberg [C# MVP]

Your statment " i use the join the create e new tables" is misleading. If you
are using a JOIN clause, you are getting back one Datatable. Therefore, your
update, assuming you are passing this table into a DataAdapter, must have SQL
that is smart enough to know which columns belong to which of the original
joined tables and take care of updating each table.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
 
C

Cor Ligthert[MVP]

Baddy,

A Select with joined tables creates one resultset which is by you gotten as
I have read ir right using the Fill from the SqlDataAdapter.

There is no information from where the table comes, where the fields are
from, how much it is compressed etc etc.

The only possibility you have is to create your own Insert, Update and
Delete SQL scripts (sprocs or just as inline text in your DBlayer) and then
process those with seperate ADONet SqlClient.SQLExecuteNonQuery Commands.

Be aware that you have to do then yourself all concurency checking,
relational checing and act row by row what to do. In my idea a hell of a
job. I don't think that this is ever really done in a production
environment. For sure I have never seen samples about that in .Net
newsgroups.

For this kind of jobs are seperated Related DataTables used inside a DataSet
or whatever. (Aroud those are tools to create the needed Update, Delete, and
Insert scripts.). If it is about one none related sinlge datatable (not
joined) with less than 100 fields you can use as well then the
SqlClient.SqlCommandbuilder.

This is for versions before 2008, however I am me not aware that there has
changed anything about this in version 2008.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top