string sqlCon = @"Data Source=.\SQLEXPRESS;" +
@"AttachDbFilename=|DataDirectory|\SampleDB.mdf;
Integrated Security=True;
Connect Timeout=30;
User Instance=True";
SqlConnection Con = new SqlConnection(sqlCon);
The filepath should have |DataDirectory| which actually links to "current project directory\App_Data\" or "current project directory" and get the .mdf file.....Place the .mdf in either of these places and should work in visual studio 2010.And when you use the standalone application on production system, then the current path where the executable file is, should have the .mdf file.