Ok! Thanks Dries...
The SqlDataAdapter is of course the class that ADO.NET will use to transfer
data between a Dataset and persistent storage.
The core in my question is really what is the best practices to obtain the
SqlCommand instance for the current state of my dataset...
In other words: I donīt want to write the extreme amount of sql manually
that such an update would require...
///
I donīt want 1000 rows of this with coresponding sprocs:
// Establish our Insert, Delete, and Update commands
DBCommandWrapper insertCommandWrapper =
db.GetStoredProcCommandWrapper("AddProduct");
insertCommandWrapper.AddInParameter("@CategoryID", DbType.Int32,
"CategoryID", DataRowVersion.Current);
insertCommandWrapper.AddInParameter("@UnitPrice", DbType.Currency,
"UnitPrice", DataRowVersion.Current);
DBCommandWrapper deleteCommandWrapper =
db.GetStoredProcCommandWrapper("DeleteProduct");
deleteCommandWrapper.AddInParameter("@ProductID", DbType.Int32, "ProductID",
DataRowVersion.Current);
DBCommandWrapper updateCommandWrapper =
db.GetStoredProcCommandWrapper("UpdateProduct");
updateCommandWrapper.AddInParameter("@ProductID", DbType.Int32, "ProductID",
DataRowVersion.Current);
updateCommandWrapper.AddInParameter("@LastUpdate", DbType.DateTime,
"LastUpdate", DataRowVersion.Current);
///
So basically should I use the SqlCommandBuilder class here? Or what? What
support(or rather recommendations..) is there for Entlib here?
Maybee I am just stupid here..but I would rely like some advice.. ->
pointers to best practices code here...
/Oscar
"Dries De Rudder" <dr***@bestopia.be> wrote in message
news:11***************@seven.kulnet.kuleuven.ac.be ...
Just use the SqlDataAdapter!
you can look for it on the msdn website msdn.microsoft.com/library en
search for the SqlDataAdapter class, there will be an example of how to
load and save data by using the DataAdapter class.
greetz
Oscar Thornell schreef: Hi,
I have a relativley large/complex typed dataset that contains 7-8 tables
and some supporting relational tables (lookups) for many-to-many
relations. A good exampel would be a dataset that contained the whole
Northwind database with all tables and relations.
In my business logic I will retrive a populated instance of the dataset
and perform some operations (adding/deleting/updating of rows in various
tables...).
What is the best way to persist these changes back to the database (SQL
Server)?.
I would rely appreciate a link to a relativly complete exampel or if
someone could detail how/and what best practices is for a scenario like
this one.
Regards
/Oscar