Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
Help:New Table from DataSet to DataBase???
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.adonet.


Marc Sander
GOOD ANSWER
I have create a new Table in a DataSet with Clone and ImportRow. But, how
can I get the new Table to my DataBase with the OleDbDataAdopter?

I have try it with:

Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder(oleadapter)

oleds.Tables.Add(sqlds.Tables("test").Clone)

For i = 0 To sqlds.Tables("test").Rows.Count - 1

oleds.Tables("test").ImportRow(sqlds.Tables("test").Rows(i))

Next i

oleadapter.Update(oleds.Tables("test"))

All Data is in the DataSet, but nothing happend in the Database.

Thx for Help

Marc

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Hussein Abuthuraya(MSFT)
GOOD ANSWER
Marc,

The DataAdapter when Updating a DataBase from a DataSet, scans all rows and check their RowState. If the RowState is Added then the DataAdapter
executes the InsertCommand (that was generated from the CommandBuilder, in your case). If the RowState is Deleted or Modified then it executes the
DeleteCommand or the UpdateCommand, respectively.

So if the RowState "UnChanged" then no Command will be executed. If you check the RowState of some of the rows you will see it as "Unchanged" and this is
the reason why no records are inserted. The RowState will be "Added" only if you add new rows to the Table in the DataSet.

I'm not sure if ImportRow also imports the RowState but check the states of the rows before the Import and after and it should point what is going on.

I hope this helps!

Thanks,
Hussein Abuthuraya
Microsoft Visual Studio .NET Readiness Team

This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use. © 2001 Microsoft Corporation. All rights reserved

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
 
System.Data.Common.DataAdapter
System.Data.DataSet
System.Data.OleDb.OleDbCommandBuilder
System.Web.UI.WebControls.Table




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734