dataset/database update

  • Thread starter Marie-Christine Bechara
  • Start date
M

Marie-Christine Bechara

i have a webservice that returns a dataset holding all categories.
i want to enter these rows in the database by calling the data
adapter's update method.
i'm doing the following but no update to my database is made. why is
that?


Code:
this.dsetMustaqbal = currentIssueWS.GetCategories();

this.sqlDataAdapter1.Update(this.dsetMustaqbal,"Categories");
 
N

Nicholas Paldino [.NET/C# MVP]

Marie,

The reason is that when the dataset is passed to you, it is not listed
as being changed in any way. You have to modify the row in order for the
adapter to pick it up.

If you are using .NET 2.0 or above, you can call the SetAdd method on
the DataRow object to set the state to add (assuming you want to add it).
If not, then you should create a table with a similar structure, and insert
new rows into it from the old data table, so that the state is set to added.
Then, when you pass this to the adapter, it will insert the rows in the
table.

Hope this helps.
 
M

Marie-Christine Bechara

I am using studio 2003.
I i must add rows from the old data table, then there will be a for loop
on the datarows of the old one.The for loop will take time in case of
large numbers of records.

There is no where to avoid adding a temporary table and copying its rows
to my dataset??
 

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