How to specify the location of the SDF file using SqlCeConnection
Connection string
This .NET Compact Framework Data Provider for SQL Server Mobile connection string can be used for connections to SQL Server Compact.
Often times the .SDF database is not running in the current directory so it becomes necessary to programatically set the path to the SDF file. This is an example (.net C#) on how to do this when the SDF file is located in the same directory as the executing application.
Data Source=" + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\MyData.sdf;
Persist Security Info=False;