|
| 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
|
|
|
| |
|
|
| |
| |
| 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
|
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|