How do I connect to SDF on a Mobile device from desktop application?

Posted by pitprog on Stack Overflow See other posts from Stack Overflow or by pitprog
Published on 2009-10-24T18:29:55Z Indexed on 2010/04/04 14:03 UTC
Read the original article Hit count: 658

C# WinForms .Net 3.5 to SQL CE 3.5 on Mobile 6.1 Device

I'd like to make a connection from a desktop application to a SDF database on my Windows Mobile device while it's connected via ActiveSync. Visual Studio lets me create a Data Connection to my device. The connections tests OK and I can view the data in the database using Visual Studio.

I then create a form and try to fill a DataGridView. When I run the program I get an error that the path to the data base is not valid.

How am I supposed to specify the Mobile device path in the connection string?

In my App.Config, I've tried variations on the path, but none of them work:

connectionString="Data Source=Mobile Device\Program Files\SqlCeViaActiveSync\Orders.sdf"

connectionString="Data Source=\Mobile Device\Program Files\SqlCeViaActiveSync\Orders.sdf"

connectionString="Data Source=Program Files\SqlCeViaActiveSync\Orders.sdf"

connectionString="Data Source=\Program Files\SqlCeViaActiveSync\Orders.sdf"

The full connection string section looks like this:

<connectionStrings>
    <add name="SqlCeViaActiveSync.Properties.Settings.OrdersConnectionString"
        connectionString="Data Source=Mobile Device\Program Files\SqlCeViaActiveSync\Orders.sdf"
        providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>

Also, I did make a reference to Microsoft.SqlServerCe.Client, as I found a few articles that mentioned it was necessary.

Can anyone point me to some recent articles/samples or let me know what I'm doing wrong?

Thanks!

© Stack Overflow or respective owner

Related posts about sdf

Related posts about activesync