Search code examples
c#sql-server-ce

Connecting to local SQL Server CE database issue?


I have a connection string inside my app.config file.

<connectionStrings>
    <add name="ConnString" 
         connectionString="Data Source=|DataDirectory|\STOCK.sdf; Persist Security Info=False;" 
         providerName="Microsoft.SqlServerCe.Client.3.5"/>
</connectionStrings>

But I have got the following error: when accessing it:

enter image description here

Note: previously I had problem saving the data, and I changed the .sdf property to "Do not Copy", after that this error is happening.


Solution

  • You should use Server Explorer in Visual Studio to get connection string. Refer here: http://www.codeproject.com/Tips/314772/Using-Visual-Studio-to-find-a-database-connection

    Hope this help.