示例#1
0
 /// <summary>
 /// Creates connection string from the provider values
 /// </summary>
 public static string CreateSqlServerConnectionString(ConnectionStringRequest request)
 {
     try
     {
         var builder = new SqlConnectionStringBuilder
         {
             IntegratedSecurity = request.IntegratedSecurity,
             DataSource         = request.ServerName,
             InitialCatalog     = request.DatabaseName
         };
         if (!request.IntegratedSecurity)
         {
             builder.UserID   = request.UserName;
             builder.Password = request.Password;
         }
         builder.PersistSecurityInfo = false;
         if (request.Timeout > 0)
         {
             builder.ConnectTimeout = request.Timeout;
         }
         return(builder.ConnectionString);
     }
     catch
     {
         return(string.Empty);
     }
 }
示例#2
0
 public static string CreateConnectionString(ConnectionStringRequest request)
 {
     if (request.ProviderName == SqlServerProvider)
     {
         return(CreateSqlServerConnectionString(request));
     }
     if (request.ProviderName == MySqlProvider)
     {
         return(CreateMysqlConnectionString(request));
     }
     return(null);
 }
示例#3
0
 public static string CreateMysqlConnectionString(ConnectionStringRequest request)
 {
     return($"Server={request.ServerName};Database={request.DatabaseName};Uid={request.UserName};Pwd={request.Password};");
 }