This is what I have in my code:

This is what I have in my code:

static void Main(string[] args)
// Create a new SqlConnectionStringBuilder and // initialize it with a few name/value pairs. SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(GetConnectionString()); builder["Trusted_Connection"] = true; Console.WriteLine(builder.ConnectionString); SqlConnection connection = new SqlConnection(builder.ConnectionString); Console.WriteLine("Press Enter to finish."); Console.ReadLine();
} private static string GetConnectionString() {
// To avoid storing the connection string in your code, // you can retrieve it from a configuration file. return "Server=.\\SQLEXPRESS;Integrated Security=SSPI;" + "Initial Catalog=CDStore";

have looked at many posts, but none of them have been helpful. My application and my database are on my local machine. I have tried giving the actual name of the Server, and the complete path of the database, but to no avail.

Here is the error I am getting.

connection.ServerVersion threw an exception of type System.InvalidOperationException.

I would appreciate any help in this regard.