Occasionally Connected application help

jasonwucinski

Member
Joined
Mar 30, 2010
Messages
8
Programming Experience
1-3
hi everyone, I'm really hoping someone can help. this is my first attempt at making an OCA. when i insert my data into my local database, i do it like this:

VB.NET:
        Dim someName As String = Me.TextBox1.Text


        Using connection As New SqlCeConnection("Data Source = D:\Visual Studio\Projects\Work_Link_New_Applicant\Work_Link_New_Applicant\dbWorkLink.sdf;" _
        & "File Mode=Exclusive;")

            Using command As New SqlCeCommand("INSERT INTO tblWorkLink_ID(WorklinkID) VALUES (@Name)", connection)

                command.Parameters.AddWithValue("@Name", someName)
                connection.Open()
                command.ExecuteNonQuery()

            End Using

        End Using

This will insert the data into the table, but when i sync it, like this:

VB.NET:
        Dim syncAgent As LocalDataCache1SyncAgent = New LocalDataCache1SyncAgent()
        Dim syncStats As Microsoft.Synchronization.Data.SyncStatistics = syncAgent.Synchronize()
      Me.DbWorkLinkDataSet.tblWorkLink_ID.Merge(TblWorkLink_IDTableAdapter.GetData())

it wont sync, unless I save the data to the local db, then restart, and then sync. Is it because the data is just being saved to the DataSet and not being committed to the real DB until after restart? if so, how do i save the data to the Dataset, and then commit it to the real table?

thanks
jason
 
thanks for your help. im still new to this. how do i do that? i tried this:
Me.TblWorkLink_IDTableAdapter.Fill(TblWorkLink_IDTableAdapter.GetData())

but, this doesnt seem to help
 
You should be able to refill the table using this syntax.

VB.NET:
Me.TableAdapterName.Fill(Me.DataSetName.DataTableName)

I've seen this syntax floating around suggesting you can merge the changes with your existing dataset as well.

VB.NET:
Me.DataSetname.DataTableName.Merge(Me.TableAdapterName.GetData())

Make sure in your database properties that you haven't set it to overwrite every time.
 
Back
Top