G
Guest
I have reached my wits end with this and am in need of help!
I have a webservice that returns a dataset. I want to take this incoming
dataset, add a field to it (storeID), then merge this dataset with a seperate
dataset from a master table that contains the exact same fields, with an
additional MasterID (autoinc) field. I have the following code that doesn't
throw an error, but no update occurs in the master database.
========================================
CODE:
========================================
For iTableCount = 0 To fn_IncomingDS.Tables.Count - 1
fn_LocalTable = fn_IncomingDS.Tables(iTableCount).TableName
Dim da_LocalData As New SqlDataAdapter("SELECT * FROM " &
fn_LocalTable, objConn)
' Create an instance of a DataSet, and add data to the
Incoming table.
Dim dsLocal As New DataSet(fn_LocalTable)
da_LocalData.FillSchema(dsLocal, SchemaType.Mapped,
fn_LocalTable)
da_LocalData.Fill(dsLocal, fn_LocalTable)
Dim colInt32 As DataColumn = New DataColumn("TheatreID")
colInt32.DataType = System.Type.GetType("System.Int32")
fn_IncomingDS.Tables(iTableCount).Columns.Add(colInt32)
For Each row In fn_IncomingDS.Tables(iTableCount).Rows
row("StoreID") = fn_StoreID
Next
fn_IncomingDS.Tables(iTableCount).AcceptChanges()
'This is just for debugging/visual purposes
fn_Grid.DataSource = fn_IncomingDS
'When I display the resulting Dataset in a datagrid, it looks
PERFECT, with MasterID's, etc...
dsLocal.Merge(fn_IncomingDS.Tables(iTableCount), True,
MissingSchemaAction.AddWithKey)
If iTableCount = 0 Then
fn_Local.DataSource = dsLocal
End If
dsLocal.AcceptChanges()
Dim objCommandBuilder As New SqlCommandBuilder(da_LocalData)
da_LocalData.Update(dsLocal, fn_LocalTable)
'I get NO errors here, but the update doesn't occur.
Next
objConn.Close()
======================================
END CODE
======================================
Now, in testing, I've replaced the DS.MERGE with code that manually adds a
row to DSLOCAL, and the update runs fine.
Any help or pointers would be greatly appreciated!
-Ray!!!
I have a webservice that returns a dataset. I want to take this incoming
dataset, add a field to it (storeID), then merge this dataset with a seperate
dataset from a master table that contains the exact same fields, with an
additional MasterID (autoinc) field. I have the following code that doesn't
throw an error, but no update occurs in the master database.
========================================
CODE:
========================================
For iTableCount = 0 To fn_IncomingDS.Tables.Count - 1
fn_LocalTable = fn_IncomingDS.Tables(iTableCount).TableName
Dim da_LocalData As New SqlDataAdapter("SELECT * FROM " &
fn_LocalTable, objConn)
' Create an instance of a DataSet, and add data to the
Incoming table.
Dim dsLocal As New DataSet(fn_LocalTable)
da_LocalData.FillSchema(dsLocal, SchemaType.Mapped,
fn_LocalTable)
da_LocalData.Fill(dsLocal, fn_LocalTable)
Dim colInt32 As DataColumn = New DataColumn("TheatreID")
colInt32.DataType = System.Type.GetType("System.Int32")
fn_IncomingDS.Tables(iTableCount).Columns.Add(colInt32)
For Each row In fn_IncomingDS.Tables(iTableCount).Rows
row("StoreID") = fn_StoreID
Next
fn_IncomingDS.Tables(iTableCount).AcceptChanges()
'This is just for debugging/visual purposes
fn_Grid.DataSource = fn_IncomingDS
'When I display the resulting Dataset in a datagrid, it looks
PERFECT, with MasterID's, etc...
dsLocal.Merge(fn_IncomingDS.Tables(iTableCount), True,
MissingSchemaAction.AddWithKey)
If iTableCount = 0 Then
fn_Local.DataSource = dsLocal
End If
dsLocal.AcceptChanges()
Dim objCommandBuilder As New SqlCommandBuilder(da_LocalData)
da_LocalData.Update(dsLocal, fn_LocalTable)
'I get NO errors here, but the update doesn't occur.
Next
objConn.Close()
======================================
END CODE
======================================
Now, in testing, I've replaced the DS.MERGE with code that manually adds a
row to DSLOCAL, and the update runs fine.
Any help or pointers would be greatly appreciated!
-Ray!!!