views:

57

answers:

2

I would like to do something like this (pseudo code):

var Customer = select * from customer from my database

doManyThings

Restore varCustomer to Database

I can't use LINQ-to-SQL because I have a hierarchyID.

How do I this using DataTable, DataReader or other options?

+1  A: 

take a look at this article: http://www.developerfusion.com/article/4278/using-adonet-with-sql-server/4/

specifically, the section on adding, deleting, and updating rows.

Michael Abdelmalek
I'm sorry but I don't understand really how it works.Do you have a minimal example ?thanks for your help
Tim
A: 

this is what I'm doing :

SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT * FROM Customer", (SqlConnection)connection);
DataSet myDataset = new DataSet();
dataAdapter.Fill(myDataset);

// changes to the database are made by something else
...

// trying to restore the data :
if (myDataset.HasChanges())
{

    myDataset.AcceptChanges();
}

But myDataset.HasChanges() always return false. Of course, because changes are not made within this dataset.

How to tell him to force to update ?

The same thing if I use :

dataAdapter.Update(myDataset);

thanks in advance for any help

Tim