string BuildConnectionString(string databaseName = null)
{
var csb = new SqlConnectionStringBuilder();
csb.DataSource = _viewModel.Server;
csb.IntegratedSecurity = !_viewModel.UseSqlAuthentication;
if (!csb.IntegratedSecurity)
{
csb.UserID = _viewModel.UserName;
csb.Password = _viewModel.Password;
}
csb.ApplicationName = Assembly.GetExecutingAssembly().GetName().Name;
if (databaseName != null) csb.InitialCatalog = databaseName;
return csb.ConnectionString;
}