locked
Browse SDF file for Sync RRS feed

  • Question

  • I have created a desktop app (vs 2008), created a sync to an SDF file & have created a mobile app using that SDF file.

     

    Is there a way to browse for the SDF file on the mobile device to specify the SDF database?

     

    EDIT:  I want to browse to set the connection string.  I can add the DB file in VS 2008 (data connections) and it works fine, but it won't work in my application.  I browse for moble devices chekcing the box "ActiveSync Connected Device".

    The connection string looks like this "Data Source=Mobile Device\Program Files\FitTrackMobile\NWBSQL.sdf;Max Database Size=2047"

     

    Here is the code from my desktop app.:

     

    Code Snippet

    Public Class DeviceSync

    Private Sub DeviceSync_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    MDIMain.CloseAllChildren()

    Me.ProgressBar1.Style = ProgressBarStyle.Blocks

    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

    ' Call SyncAgent.Synchronize() to initiate the synchronization process.

    ' Synchronization only updates the local database, not your project’s data source.

    Try

    Dim syncAgent As DatabaseSyncSyncAgent = New DatabaseSyncSyncAgent()

    Dim syncStats As Microsoft.Synchronization.Data.SyncStatistics = syncAgent.Synchronize()

    'With Me.NWBSQLDataSet

    ' .daily_meals_table.Merge(Me.Daily_meals_tableTableAdapter.GetData)

    ' .weight_train_log.Merge(Me.Weight_train_logTableAdapter.GetData)

    ' .daily_supplementation.Merge(.daily_supplementation.get

    'End With

    Catch ex As Exception

    MsgBox(ex.Message)

    End Try

    End Sub

    Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted

    Me.Label1.Text = "Sync Complete!"

    MsgBox("Sync Complete")

    With TrainingLog

    .MdiParent = MDIMain

    .Show()

    .Dock = DockStyle.Fill

    End With

    Me.Close()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    If Me.OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

    Me.ClientNWBSQLLocationTextBox.Text = Me.OpenFileDialog1.FileName

    My.Settings.Save()

    End If

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    Try

    Me.Label1.Text = "Synchronizing Device, Please Wait..."

    My.Settings.SetUserOverride("ClientNWBSQLConnectionString", "Data Source=" & Me.ClientNWBSQLLocationTextBox.Text & ";Max Database Size=2047")

    Me.ProgressBar1.Style = ProgressBarStyle.Marquee

    BackgroundWorker1.RunWorkerAsync()

    Catch ex As Exception

    MsgBox(ex.Message)

    End Try

    End Sub

    End Class

     

     

    • Moved by Max Wang_1983 Friday, April 22, 2011 7:54 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Thursday, May 1, 2008 12:32 AM

Answers

  • OK.  Figured out this won't work.

     

    To solve it, I used OpenNetCF

     

    It works great.  I copied the SDF to a location on my HDD from the device, did the sync then copied back.

     

     

    Friday, May 2, 2008 12:56 AM