Sql server Ce connection.

  • Can anyone please help me ... its urgent....

    I am working with PDA application but not able to connect to .sdf file. I am using following connection string

    SqlCeConnection con = new SqlCeConnection("Data Source =.\\TestDB.sdf; Password =testdb;");

    but it is giving me error like: --

    The database file cannot be found. Check the path to the database. [ File name = .\TestDB.sdf ]

    Please tell me where I am going wrong.

    Thanks in advance.

  • DataSource should be the name of the server and Initial Catalog will be the name of the database in the connection string. The database will have your mdf, ldf and sdf files ir so. You can't directly read the contents of the file.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

  • Hey Sugesh,

    Nice to see your reply. Thanks a lot.

    But I want to connect to mobile database...which is in .sdf file format..

    Can you please explain more about it.

    Regards,

    Neeta

  • The BOL of SQL server CE gives you the method to create the connection string. The only thing happening here is you are not able to give the file to the application. It can be that the BUILD ACTION of the (SDF) file might be set to nothing. change this to content.

    Second thing you will have to look into is connection string you are specifying try giving it the folder in which your application is running.

    By the way which version of Visual studio are you using.

    Rajesh.

    MBA-IT (Software Dev. & Mgmt)

    SCIT 2007-09

  • Replace this following

    Public conn As New SqlCeConnection("Data Source = \My Documents\test.sdf")

    thanxxxxxx

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply