Пример #1
0
        /// <summary>
        /// Builds a connection string based on the connection settings.
        /// </summary>
        private string BuildConnectionsString()
        {
            DataSourceType dataSourceType = (DataSourceType)cbDataSourceType.SelectedIndex;

            DbConnSettings connSettings = new DbConnSettings()
            {
                Server   = txtServer.Text,
                Database = txtDatabase.Text,
                User     = txtUser.Text,
                Password = txtPassword.Text
            };

            switch (dataSourceType)
            {
            case DataSourceType.MSSQL:
                return(SqlDataSource.BuildSqlConnectionString(connSettings));

            case DataSourceType.Oracle:
                return(OraDataSource.BuildOraConnectionString(connSettings));

            case DataSourceType.PostgreSQL:
                return(PgSqlDataSource.BuildPgSqlConnectionString(connSettings));

            case DataSourceType.MySQL:
                return(MySqlDataSource.BuildMySqlConnectionString(connSettings));

            case DataSourceType.OLEDB:
                return(OleDbDataSource.BuildOleDbConnectionString(connSettings));

            default:
                return("");
            }
        }
Пример #2
0
 /// <summary>
 /// Set and show an auto-generated connection string.
 /// </summary>
 private void SetConnectionString(DbConnectionOptions dbConnectionOptions)
 {
     if (dbConnectionOptions != null)
     {
         if (dbConnectionOptions.KnownDBMS == KnownDBMS.Oracle)
         {
             txtConnectionString.Text = OraDataSource.BuildOraConnectionString(dbConnectionOptions, true);
         }
         else if (dbConnectionOptions.KnownDBMS == KnownDBMS.PostgreSQL)
         {
             txtConnectionString.Text = PgSqlDataSource.BuildPgSqlConnectionString(dbConnectionOptions, true);
         }
         else if (dbConnectionOptions.KnownDBMS == KnownDBMS.MySQL)
         {
             txtConnectionString.Text = MySqlDataSource.BuildMySqlConnectionString(dbConnectionOptions, true);
         }
         else if (dbConnectionOptions.KnownDBMS == KnownDBMS.MSSQL)
         {
             txtConnectionString.Text = SqlDataSource.BuildSqlConnectionString(dbConnectionOptions, true);
         }
         else
         {
             txtConnectionString.Text = "";
         }
     }
 }