Sql server Ce connection.

  • Neeta Patil

    SSC-Addicted

    Points: 432

    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.

  • Sugesh Kumar

    One Orange Chip

    Points: 27311

    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

  • Neeta Patil

    SSC-Addicted

    Points: 432

    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

  • Rajesh Patil

    SSC Veteran

    Points: 219

    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

  • pravingpatil2081

    Valued Member

    Points: 74

    Replace this following

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

    thanxxxxxx

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

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