Suppose I have created a SQL Server database called Database1.mdf in the App_Data folder in Visual Studio with a table called Names. <
Database1.mdf
App_Data
Names
I like to use the handy process outlined here to build connection strings using a .udl file. This allows you to test them from within the udl file to ensure that you can connect before you run any code.
Hope that helps.