Reputation: 469
I'm using a SQL Server CE .sdf
database file and I configure this database in the app.config
using this <connectionStrings>
tag:
<connectionStrings>
<add name="ReviewsDBConnection"
connectionString="data source="E:\GoogleDrive\bin\Debug\Data\ReviewsDB.sdf";password=123"
providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
But whenever I move my project (the whole solution) to another PC, I get an error which says the ReviewsDB.sdf
file path is not correct.
What should I write for data source that won't need to be changed when I move the solution to another PC? I'm using Telerik Open Access to get access to database.
Upvotes: 1
Views: 2025
Reputation: 161
As far as I understand you, you need to set relative path to the database in the connection string. If this is the case, with Telerik Data Access and SQL Server CE you can achieve it like this:
Provide the connection string like this:
<connectionStrings>
<add name="ReviewsDBConnection"
connectionString="data source=|DataDirectory|\ReviewsDB.sdf;password=123"
providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
Run the app for a test.
Upvotes: 2