I trying connect to my .MDF file but I am not able to accomplish it. I tried various variations of connection strings but still getting this same error.
This my connection string from app.config
<connectionStrings>
<add name="DBConnection"
connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\iseo-db.mdf;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
and this is how I call this connection string
private string connection = System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ToString();
SqlCeConnection con = new SqlCeConnection(connection);
When every I try execute I get a exception saying
Keyword not supported: 'attachdbfilename'
I would really appreciate any help on this problem.
.mdfis a database file for the full SQL Server - NOT SQL Server CE. And the full SQL Server supports theAttachDbFileName=statement only in the SQL Server Express edition. For SQL Server CE, you need to use a.sdfdatabase file, and anotherproviderNamein your connection string, too - marc_s