J
Jay Balapa
Hello,
Iam trouble updating my local version sql server database from a webservice
which returns a dataset. I call update but no rows are added any help will
greatly be appreciated. I have already verified that the webservice dataset
already has valid data.
Here is the code snippet.
Public Shared Sub SetSyncDataset(ByVal myOldDataset As DataSet)
Try
Dim myDataset As DataSet = New DataSet()
Dim cn As System.Data.SqlServerCe.SqlCeConnection
Dim myAdapter As System.Data.SqlServerCe.SqlCeDataAdapter
Dim connStr As String = "Data Source = " &
SQLDatabase.NewRootDir & "vvvv.sdf" & "; Password =xyxx"
cn = New System.Data.SqlServerCe.SqlCeConnection(connStr)
cn.Open()
myAdapter = New System.Data.SqlServerCe.SqlCeDataAdapter("SELECT
* FROM MGUSERS WHERE 1=0", cn)
myAdapter.FillSchema(myDataset, SchemaType.Source, "MGUSERS")
myAdapter.Fill(myDataset, "MGUSERS")
Dim cb As SqlCeCommandBuilder = New SqlCeCommandBuilder(myAdapter)
myAdapter.MissingMappingAction =
MissingMappingAction.Passthrough
myAdapter.InsertCommand = cb.GetInsertCommand()
myAdapter.Update(myOldDataset, "MGUSERS")
myAdapter.Dispose()
' Close the database.
cn.Close()
Catch e As SqlCeException
MessageBox.Show(e.Message)
End Try
End Sub
Iam trouble updating my local version sql server database from a webservice
which returns a dataset. I call update but no rows are added any help will
greatly be appreciated. I have already verified that the webservice dataset
already has valid data.
Here is the code snippet.
Public Shared Sub SetSyncDataset(ByVal myOldDataset As DataSet)
Try
Dim myDataset As DataSet = New DataSet()
Dim cn As System.Data.SqlServerCe.SqlCeConnection
Dim myAdapter As System.Data.SqlServerCe.SqlCeDataAdapter
Dim connStr As String = "Data Source = " &
SQLDatabase.NewRootDir & "vvvv.sdf" & "; Password =xyxx"
cn = New System.Data.SqlServerCe.SqlCeConnection(connStr)
cn.Open()
myAdapter = New System.Data.SqlServerCe.SqlCeDataAdapter("SELECT
* FROM MGUSERS WHERE 1=0", cn)
myAdapter.FillSchema(myDataset, SchemaType.Source, "MGUSERS")
myAdapter.Fill(myDataset, "MGUSERS")
Dim cb As SqlCeCommandBuilder = New SqlCeCommandBuilder(myAdapter)
myAdapter.MissingMappingAction =
MissingMappingAction.Passthrough
myAdapter.InsertCommand = cb.GetInsertCommand()
myAdapter.Update(myOldDataset, "MGUSERS")
myAdapter.Dispose()
' Close the database.
cn.Close()
Catch e As SqlCeException
MessageBox.Show(e.Message)
End Try
End Sub