This is what I use for ConnectionString. Much simpler than all of the code you show in your example. You do not need the
using
statements for Microsoft.SqlServer.Management.Smo and Microsoft.SqlServer.Management.Common. The code below works for SQL Server Express on local PC or on a server.
using System.Data.SqlClient;
public static string cnString=@"Database=MyDatabaseName;Server=MyServerName\SQLEXPRESS;Connect timeout=15;Integrated security=True;Net=dbmssocn;Application name=MyAppName;";
public static SqlConnection srvConn= new SqlConnection(cnString);
srvConn.Open();