Connection string for SqlCeConnection

Which format is assumed for connection string for SqlCeConnection
In help topics there are only examples like this: 

... Data Source = 'SalesData.sdf'; ...

But this example is intended for SQL Server 2005 Mobile database located on desktop computer...

I need to custom data load from desktop to device and vice versa, so I did this:

string SqlMobileConnString = "Persist Security Info = False; Data Source = Mobile Device\CF Card\mBase.sdf; File Mode = 'shared read';";

SqlCeConnection
SqlMobileConn;
SqlMobileConn = new SqlCeConnection(SqlMobileConnString);
SqlMobileConn.Open();

// Exception!!! Invalid path... I tried to set path like this: "Data Source = My Computer\Mobile Device\..." and old variant with slash: "Data Source = \Mobile Device\...", but nothing was helpful... It's very strange because even SQL Server Management Studio uses this format: "Data Source = Mobile Device\..."

I only know that this format is intended to use from mobile applications:
"Data Source = \CF Card\...". It's quite simple and logically ...

So I don't know what to do... Please help!

P.S. Sorry for my english :)



Answer this question

Connection string for SqlCeConnection

  • ChrisWall

    How can i do it in VB.NET

    Thanks

    Fabio


  • Firestorm353

    Microsoft.SqlServerCe.Client.dll is not supported and hence not documented. 

    Thanks,
    Laxmi NRO, SQL Mobile, Microsoft

  • anthonyjl

    in most instances,you have to replace SqlCommand with SqlCeCommand , XxxYxx with XxxCeYyy
    (my app was for windows ce 5.0 for symbol 3000 handheld and pocket pc ).

      to connect ms sql management studio to .sdf file on visual studio seems to require the non express edition of the  sql management studio



  • Matthieu Massin

    \ should be escaped as \\ in C#.
    Or please use verbatim strings by adding @ to the string.

  • AntC999

    hi, i'm trying to connect to a sdf file from a windows application and the VS2005 tellsme that i need the seql server mobile 3.0, i thought this was installed with the vs, what should i do, please give me hand with this. thanks



  • Scott.Berry

    You need to have the Smart Device Programmability option installed (VS 2005 Std or higher). See this blog entry for the full development environment story: http://blogs.msdn.com/stevelasker/archive/2007/08/07/configuring-visual-studio-2005-for-use-wtih-sql-server-2005-compact-edition.aspx



  • Da4582

    Oh, string is ok, I forgot to set @ here (in code everything was OK).

    But I've solved problem with connection!

    I used namespace Microsoft.SqlServerCe.Client instead of System.Data.SqlServerCe, in which I found classes identical to classes from the latter one.

    Instance of Microsoft.SqlServerCe.Client.SqlCeConnection class connected to my SQL Server 2005 Mobile database on PocketPC through ActiveSync and I viewed data from it on my desktop computer.

    Only one question: Where I can find some detailed info about this namespace
    It is located in

    C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\Microsoft.SqlServerCe.Client.dll

    or

    C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Microsoft.SqlServerCe.Client.dll

    I've found no information about this namespace (as for me I've found it searching files *sqlserverce*.dll in My Computer :)

    Maybe it is not documented yet...


  • Connection string for SqlCeConnection