private bool SelectConnection(DesignerDataConnection conn)
 {
     if (conn.IsConfigured)
     {
         foreach (DataConnectionItem item in this._connectionsComboBox.Items)
         {
             DesignerDataConnection designerDataConnection = item.DesignerDataConnection;
             if (designerDataConnection.IsConfigured && (designerDataConnection.Name == conn.Name))
             {
                 this._connectionsComboBox.SelectedItem = item;
                 return(true);
             }
         }
     }
     else
     {
         foreach (DataConnectionItem item2 in this._connectionsComboBox.Items)
         {
             DesignerDataConnection connection2 = item2.DesignerDataConnection;
             if (!connection2.IsConfigured && SqlDataSourceDesigner.ConnectionsEqual(connection2, conn))
             {
                 this._connectionsComboBox.SelectedItem = item2;
                 return(true);
             }
         }
     }
     return(false);
 }
 internal static void PersistConnectionSettings(SqlDataSource sqlDataSource, SqlDataSourceDesigner sqlDataSourceDesigner, DesignerDataConnection dataConnection)
 {
     if (dataConnection.IsConfigured)
     {
         ExpressionBindingCollection expressions = sqlDataSource.Expressions;
         PropertyDescriptor          descriptor  = TypeDescriptor.GetProperties(sqlDataSource)["ProviderName"];
         descriptor.ResetValue(sqlDataSource);
         if (dataConnection.ProviderName != "System.Data.SqlClient")
         {
             expressions.Add(new ExpressionBinding(descriptor.Name, descriptor.PropertyType, "ConnectionStrings", dataConnection.Name + ".ProviderName"));
         }
         descriptor = TypeDescriptor.GetProperties(sqlDataSource)["ConnectionString"];
         descriptor.ResetValue(sqlDataSource);
         expressions.Add(new ExpressionBinding(descriptor.Name, descriptor.PropertyType, "ConnectionStrings", dataConnection.Name));
     }
     else
     {
         PropertyDescriptor descriptor2;
         if (sqlDataSource.ProviderName != dataConnection.ProviderName)
         {
             descriptor2 = TypeDescriptor.GetProperties(sqlDataSource)["ProviderName"];
             descriptor2.ResetValue(sqlDataSource);
             descriptor2.SetValue(sqlDataSource, dataConnection.ProviderName);
         }
         if (sqlDataSource.ConnectionString != dataConnection.ConnectionString)
         {
             descriptor2 = TypeDescriptor.GetProperties(sqlDataSource)["ConnectionString"];
             descriptor2.ResetValue(sqlDataSource);
             descriptor2.SetValue(sqlDataSource, dataConnection.ConnectionString);
         }
     }
 }
Beispiel #3
0
        public SqlDataSourceRefreshSchemaForm(IServiceProvider serviceProvider, SqlDataSourceDesigner sqlDataSourceDesigner, ParameterCollection parameters) : base(serviceProvider)
        {
            this._sqlDataSourceDesigner = sqlDataSourceDesigner;
            this._sqlDataSource         = (SqlDataSource)this._sqlDataSourceDesigner.Component;
            this._connectionString      = this._sqlDataSourceDesigner.ConnectionString;
            this._providerName          = this._sqlDataSourceDesigner.ProviderName;
            this._selectCommand         = this._sqlDataSourceDesigner.SelectCommand;
            this._selectCommandType     = this._sqlDataSource.SelectCommandType;
            this.InitializeComponent();
            this.InitializeUI();
            Array values = Enum.GetValues(typeof(TypeCode));

            Array.Sort(values, new TypeCodeComparer());
            foreach (TypeCode code in values)
            {
                ((DataGridViewComboBoxColumn)this._parametersDataGridView.Columns[1]).Items.Add(code);
            }
            Array array = Enum.GetValues(typeof(DbType));

            Array.Sort(array, new DbTypeComparer());
            foreach (DbType type in array)
            {
                ((DataGridViewComboBoxColumn)this._parametersDataGridView.Columns[2]).Items.Add(type);
            }
            ArrayList list = new ArrayList(parameters.Count);

            foreach (Parameter parameter in parameters)
            {
                list.Add(new ParameterItem(parameter));
            }
            this._parametersDataGridView.DataSource = list;
            this._commandTextBox.Text = this._selectCommand;
            this._commandTextBox.Select(0, 0);
        }
 public SqlDataSourceConfigureParametersPanel(SqlDataSourceDesigner sqlDataSourceDesigner)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this.InitializeComponent();
     this.InitializeUI();
     this._parameterEditorUserControl.SetAllowCollectionChanges(false);
 }
 public SqlDataSourceDataConnectionChooserPanel(SqlDataSourceDesigner sqlDataSourceDesigner, IDataEnvironment dataEnvironment) : base(sqlDataSourceDesigner)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this._sqlDataSource = (SqlDataSource) this._sqlDataSourceDesigner.Component;
     this._dataEnvironment = dataEnvironment;
     this.InitializeComponent();
     this.InitializeUI();
     DesignerDataConnection conn = new DesignerDataConnection(System.Design.SR.GetString("SqlDataSourceDataConnectionChooserPanel_CustomConnectionName"), this._sqlDataSource.ProviderName, this._sqlDataSource.ConnectionString);
     ExpressionBinding binding = this._sqlDataSource.Expressions["ConnectionString"];
     if ((binding != null) && string.Equals(binding.ExpressionPrefix, "ConnectionStrings", StringComparison.OrdinalIgnoreCase))
     {
         string expression = binding.Expression;
         string str2 = "." + "ConnectionString".ToLowerInvariant();
         if (expression.ToLowerInvariant().EndsWith(str2, StringComparison.Ordinal))
         {
             expression = expression.Substring(0, expression.Length - str2.Length);
         }
         ICollection connections = this._dataEnvironment.Connections;
         if (connections != null)
         {
             foreach (DesignerDataConnection connection2 in connections)
             {
                 if (connection2.IsConfigured && string.Equals(connection2.Name, expression, StringComparison.OrdinalIgnoreCase))
                 {
                     conn = connection2;
                     break;
                 }
             }
         }
     }
     this.SetConnectionSettings(conn);
 }
 public SqlDataSourceRefreshSchemaForm(IServiceProvider serviceProvider, SqlDataSourceDesigner sqlDataSourceDesigner, ParameterCollection parameters) : base(serviceProvider)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this._sqlDataSource = (SqlDataSource) this._sqlDataSourceDesigner.Component;
     this._connectionString = this._sqlDataSourceDesigner.ConnectionString;
     this._providerName = this._sqlDataSourceDesigner.ProviderName;
     this._selectCommand = this._sqlDataSourceDesigner.SelectCommand;
     this._selectCommandType = this._sqlDataSource.SelectCommandType;
     this.InitializeComponent();
     this.InitializeUI();
     Array values = Enum.GetValues(typeof(TypeCode));
     Array.Sort(values, new TypeCodeComparer());
     foreach (TypeCode code in values)
     {
         ((DataGridViewComboBoxColumn) this._parametersDataGridView.Columns[1]).Items.Add(code);
     }
     Array array = Enum.GetValues(typeof(DbType));
     Array.Sort(array, new DbTypeComparer());
     foreach (DbType type in array)
     {
         ((DataGridViewComboBoxColumn) this._parametersDataGridView.Columns[2]).Items.Add(type);
     }
     ArrayList list = new ArrayList(parameters.Count);
     foreach (Parameter parameter in parameters)
     {
         list.Add(new ParameterItem(parameter));
     }
     this._parametersDataGridView.DataSource = list;
     this._commandTextBox.Text = this._selectCommand;
     this._commandTextBox.Select(0, 0);
 }
        public SqlDataSourceDataConnectionChooserPanel(SqlDataSourceDesigner sqlDataSourceDesigner, IDataEnvironment dataEnvironment) : base(sqlDataSourceDesigner)
        {
            this._sqlDataSourceDesigner = sqlDataSourceDesigner;
            this._sqlDataSource         = (SqlDataSource)this._sqlDataSourceDesigner.Component;
            this._dataEnvironment       = dataEnvironment;
            this.InitializeComponent();
            this.InitializeUI();
            DesignerDataConnection conn    = new DesignerDataConnection(System.Design.SR.GetString("SqlDataSourceDataConnectionChooserPanel_CustomConnectionName"), this._sqlDataSource.ProviderName, this._sqlDataSource.ConnectionString);
            ExpressionBinding      binding = this._sqlDataSource.Expressions["ConnectionString"];

            if ((binding != null) && string.Equals(binding.ExpressionPrefix, "ConnectionStrings", StringComparison.OrdinalIgnoreCase))
            {
                string expression = binding.Expression;
                string str2       = "." + "ConnectionString".ToLowerInvariant();
                if (expression.ToLowerInvariant().EndsWith(str2, StringComparison.Ordinal))
                {
                    expression = expression.Substring(0, expression.Length - str2.Length);
                }
                ICollection connections = this._dataEnvironment.Connections;
                if (connections != null)
                {
                    foreach (DesignerDataConnection connection2 in connections)
                    {
                        if (connection2.IsConfigured && string.Equals(connection2.Name, expression, StringComparison.OrdinalIgnoreCase))
                        {
                            conn = connection2;
                            break;
                        }
                    }
                }
            }
            this.SetConnectionSettings(conn);
        }
 public SqlDataSourceConfigureParametersPanel(SqlDataSourceDesigner sqlDataSourceDesigner)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this.InitializeComponent();
     this.InitializeUI();
     this._parameterEditorUserControl.SetAllowCollectionChanges(false);
 }
        public override bool OnNext()
        {
            if (!base.CheckValidProvider())
            {
                return(false);
            }
            DesignerDataConnection dataConnection = this.DataConnection;

            if (!dataConnection.IsConfigured)
            {
                this._needsToPersistConnectionInfo = false;
                SqlDataSourceSaveConfiguredConnectionPanel nextPanel = base.NextPanel as SqlDataSourceSaveConfiguredConnectionPanel;
                if (nextPanel == null)
                {
                    nextPanel      = ((SqlDataSourceWizardForm)base.ParentWizard).GetSaveConfiguredConnectionPanel();
                    base.NextPanel = nextPanel;
                }
                if (!SqlDataSourceDesigner.ConnectionsEqual(dataConnection, nextPanel.CurrentConnection))
                {
                    nextPanel.SetConnectionInfo(dataConnection);
                }
                return(true);
            }
            this._needsToPersistConnectionInfo = true;
            return(base.OnNext());
        }
 public SqlDataSourceSaveConfiguredConnectionPanel(SqlDataSourceDesigner sqlDataSourceDesigner, IDataEnvironment dataEnvironment)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this._sqlDataSource         = (SqlDataSource)this._sqlDataSourceDesigner.Component;
     this._dataEnvironment       = dataEnvironment;
     this.InitializeComponent();
     this.InitializeUI();
 }
 public SqlDataSourceSaveConfiguredConnectionPanel(SqlDataSourceDesigner sqlDataSourceDesigner, IDataEnvironment dataEnvironment)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this._sqlDataSource = (SqlDataSource) this._sqlDataSourceDesigner.Component;
     this._dataEnvironment = dataEnvironment;
     this.InitializeComponent();
     this.InitializeUI();
 }
 public SqlDataSourceCustomCommandPanel(SqlDataSourceDesigner sqlDataSourceDesigner)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this.InitializeComponent();
     this.InitializeUI();
     this._selectCommandEditor.SetCommandData(this._sqlDataSourceDesigner, QueryBuilderMode.Select);
     this._insertCommandEditor.SetCommandData(this._sqlDataSourceDesigner, QueryBuilderMode.Insert);
     this._updateCommandEditor.SetCommandData(this._sqlDataSourceDesigner, QueryBuilderMode.Update);
     this._deleteCommandEditor.SetCommandData(this._sqlDataSourceDesigner, QueryBuilderMode.Delete);
 }
        public void SetQueries(DesignerDataConnection dataConnection, SqlDataSourceQuery selectQuery, SqlDataSourceQuery insertQuery, SqlDataSourceQuery updateQuery, SqlDataSourceQuery deleteQuery)
        {
            DesignerDataConnection connection = dataConnection;

            if (!SqlDataSourceDesigner.ConnectionsEqual(this._dataConnection, connection))
            {
                this._dataConnection = connection;
                Cursor    current          = Cursor.Current;
                ArrayList storedProcedures = null;
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    IDataEnvironment service = (IDataEnvironment)this._sqlDataSourceDesigner.Component.Site.GetService(typeof(IDataEnvironment));
                    if (service != null)
                    {
                        IDesignerDataSchema connectionSchema = service.GetConnectionSchema(this._dataConnection);
                        if ((connectionSchema != null) && connectionSchema.SupportsSchemaClass(DesignerDataSchemaClass.StoredProcedures))
                        {
                            ICollection schemaItems = connectionSchema.GetSchemaItems(DesignerDataSchemaClass.StoredProcedures);
                            if ((schemaItems != null) && (schemaItems.Count > 0))
                            {
                                storedProcedures = new ArrayList();
                                foreach (DesignerDataStoredProcedure procedure in schemaItems)
                                {
                                    if (!procedure.Name.ToLowerInvariant().StartsWith("AspNet_".ToLowerInvariant(), StringComparison.Ordinal))
                                    {
                                        storedProcedures.Add(procedure);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    UIServiceHelper.ShowError(base.ServiceProvider, exception, System.Design.SR.GetString("SqlDataSourceConnectionPanel_CouldNotGetConnectionSchema"));
                }
                finally
                {
                    Cursor.Current = current;
                }
                this._selectCommandEditor.SetConnection(this._dataConnection);
                this._selectCommandEditor.SetStoredProcedures(storedProcedures);
                this._insertCommandEditor.SetConnection(this._dataConnection);
                this._insertCommandEditor.SetStoredProcedures(storedProcedures);
                this._updateCommandEditor.SetConnection(this._dataConnection);
                this._updateCommandEditor.SetStoredProcedures(storedProcedures);
                this._deleteCommandEditor.SetConnection(this._dataConnection);
                this._deleteCommandEditor.SetStoredProcedures(storedProcedures);
                this._selectCommandEditor.SetQuery(selectQuery);
                this._insertCommandEditor.SetQuery(insertQuery);
                this._updateCommandEditor.SetQuery(updateQuery);
                this._deleteCommandEditor.SetQuery(deleteQuery);
            }
        }
        public void SetCommandData(SqlDataSourceDesigner sqlDataSourceDesigner, QueryBuilderMode editorMode)
        {
            this._sqlDataSourceDesigner      = sqlDataSourceDesigner;
            this._editorMode                 = editorMode;
            this._queryBuilderButton.Enabled = false;
            IServiceProvider site = this._sqlDataSourceDesigner.Component.Site;

            if (site != null)
            {
                this._dataEnvironment = (IDataEnvironment)site.GetService(typeof(IDataEnvironment));
            }
        }
        private SqlDataSourceQuery GetWhereClause(string oldValuesFormatString, bool includeOldValues)
        {
            List <SqlDataSourceColumnData> effectiveColumns = this.GetEffectiveColumns();
            List <Parameter> parameters = new List <Parameter>();

            if (effectiveColumns.Count == 0)
            {
                return(null);
            }
            StringBuilder commandText = new StringBuilder();

            commandText.Append(" WHERE ");
            int num = 0;
            DbProviderFactory dbProviderFactory = SqlDataSourceDesigner.GetDbProviderFactory(this.DesignerDataConnection.ProviderName);

            foreach (SqlDataSourceColumnData data in effectiveColumns)
            {
                if (data.Column.PrimaryKey)
                {
                    if (num > 0)
                    {
                        commandText.Append(" AND ");
                    }
                    num++;
                    this.AppendWhereClauseParameter(commandText, data, oldValuesFormatString);
                    parameters.Add(SqlDataSourceDesigner.CreateParameter(dbProviderFactory, data.GetOldValueWebParameterName(oldValuesFormatString), data.Column.DataType));
                }
            }
            if (num == 0)
            {
                return(null);
            }
            if (includeOldValues)
            {
                foreach (SqlDataSourceColumnData data2 in effectiveColumns)
                {
                    if (!data2.Column.PrimaryKey)
                    {
                        commandText.Append(" AND ");
                        num++;
                        this.AppendWhereClauseParameter(commandText, data2, oldValuesFormatString);
                        Parameter item = SqlDataSourceDesigner.CreateParameter(dbProviderFactory, data2.GetOldValueWebParameterName(oldValuesFormatString), data2.Column.DataType);
                        parameters.Add(item);
                        if (data2.Column.Nullable && !SqlDataSourceDesigner.SupportsNamedParameters(dbProviderFactory))
                        {
                            parameters.Add(item);
                        }
                    }
                }
            }
            return(new SqlDataSourceQuery(commandText.ToString(), SqlDataSourceCommandType.Text, parameters));
        }
        private string CreateParameterPlaceholder(string oldValueFormatString)
        {
            DbProviderFactory dbProviderFactory          = SqlDataSourceDesigner.GetDbProviderFactory(this._connection.ProviderName);
            string            parameterPlaceholderPrefix = SqlDataSourceDesigner.GetParameterPlaceholderPrefix(dbProviderFactory);

            if (!SqlDataSourceDesigner.SupportsNamedParameters(dbProviderFactory))
            {
                return(parameterPlaceholderPrefix);
            }
            if (oldValueFormatString == null)
            {
                return(parameterPlaceholderPrefix + this.AliasedName);
            }
            return(parameterPlaceholderPrefix + string.Format(CultureInfo.InvariantCulture, oldValueFormatString, new object[] { this.AliasedName }));
        }
        protected bool CheckValidProvider()
        {
            DesignerDataConnection dataConnection = this.DataConnection;

            try
            {
                SqlDataSourceDesigner.GetDbProviderFactory(dataConnection.ProviderName);
                return(true);
            }
            catch (Exception exception)
            {
                UIServiceHelper.ShowError(base.ServiceProvider, exception, System.Design.SR.GetString("SqlDataSourceConnectionPanel_ProviderNotFound", new object[] { dataConnection.ProviderName }));
                return(false);
            }
        }
        public SqlDataSourceQuery GetUpdateQuery(string oldValuesFormatString, bool includeOldValues)
        {
            if (!this.CanAutoGenerateQueries())
            {
                return(null);
            }
            StringBuilder builder = new StringBuilder("UPDATE ");

            builder.Append(this.GetTableName());
            builder.Append(" SET ");
            List <SqlDataSourceColumnData> effectiveColumns = this.GetEffectiveColumns();
            List <Parameter> parameters = new List <Parameter>();
            bool             flag       = true;

            foreach (SqlDataSourceColumnData data in effectiveColumns)
            {
                if (!data.Column.PrimaryKey)
                {
                    if (!flag)
                    {
                        builder.Append(", ");
                    }
                    builder.Append(data.EscapedName);
                    builder.Append(" = ");
                    builder.Append(data.ParameterPlaceholder);
                    flag = false;
                    DbProviderFactory dbProviderFactory = SqlDataSourceDesigner.GetDbProviderFactory(this.DesignerDataConnection.ProviderName);
                    parameters.Add(SqlDataSourceDesigner.CreateParameter(dbProviderFactory, data.WebParameterName, data.Column.DataType));
                }
            }
            if (flag)
            {
                return(null);
            }
            SqlDataSourceQuery whereClause = this.GetWhereClause(oldValuesFormatString, includeOldValues);

            if (whereClause == null)
            {
                return(null);
            }
            builder.Append(whereClause.Command);
            foreach (Parameter parameter in whereClause.Parameters)
            {
                parameters.Add(parameter);
            }
            return(new SqlDataSourceQuery(builder.ToString(), SqlDataSourceCommandType.Text, parameters));
        }
 public SqlDataSourceConfigureFilterForm(SqlDataSourceDesigner sqlDataSourceDesigner, SqlDataSourceTableQuery tableQuery)
     : base(sqlDataSourceDesigner.Component.Site)
 {
     this._dataSource = (SqlDataSource) sqlDataSourceDesigner.Component;
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this._tableQuery = tableQuery.Clone();
     this.InitializeComponent();
     this.InitializeUI();
     _parameterEditors = this.CreateParameterList();
     foreach (ParameterEditor editor in _parameterEditors.Values)
     {
         editor.Visible = false;
         this._propertiesPanel.Controls.Add(editor);
         this._sourceComboBox.Items.Add(editor);
         editor.ParameterChanged += new EventHandler(this.OnParameterChanged);
     }
     this._sourceComboBox.InvalidateDropDownWidth();
     Cursor current = Cursor.Current;
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         foreach (DesignerDataColumn column in tableQuery.DesignerDataTable.Columns)
         {
             this._columnsComboBox.Items.Add(new ColumnItem(column));
         }
         this._columnsComboBox.InvalidateDropDownWidth();
         foreach (SqlDataSourceFilterClause clause in this._tableQuery.FilterClauses)
         {
             FilterClauseItem item = new FilterClauseItem(this._sqlDataSourceDesigner.Component.Site, this._tableQuery, clause, (SqlDataSource) this._sqlDataSourceDesigner.Component);
             this._whereClausesListView.Items.Add(item);
             item.Refresh();
         }
         if (this._whereClausesListView.Items.Count > 0)
         {
             this._whereClausesListView.Items[0].Selected = true;
             this._whereClausesListView.Items[0].Focused = true;
         }
         this._okButton.Enabled = false;
         this.UpdateDeleteButton();
         this.UpdateOperators();
     }
     finally
     {
         Cursor.Current = current;
     }
 }
            public static string GetConnectionName(DesignerDataConnection connection)
            {
                DbConnectionStringBuilder connectionStringBuilder = SqlDataSourceDesigner.GetDbProviderFactory(connection.ProviderName).CreateConnectionStringBuilder();

                if (connectionStringBuilder == null)
                {
                    connectionStringBuilder = new DbConnectionStringBuilder();
                }
                string str = null;

                try
                {
                    object obj2;
                    connectionStringBuilder.ConnectionString = connection.ConnectionString;
                    if (IsLocalDbFileConnectionString(connection.ProviderName, connectionStringBuilder))
                    {
                        string filePathKey = GetFilePathKey(connection.ProviderName, connectionStringBuilder);
                        if (!string.IsNullOrEmpty(filePathKey))
                        {
                            string str3 = connectionStringBuilder[filePathKey] as string;
                            if (!string.IsNullOrEmpty(str3))
                            {
                                str = Path.GetFileNameWithoutExtension(str3) + "ConnectionString";
                            }
                        }
                    }
                    if ((str == null) && connectionStringBuilder.TryGetValue("Database", out obj2))
                    {
                        string s = obj2 as string;
                        if (!StringIsEmpty(s))
                        {
                            str = s + "ConnectionString";
                        }
                    }
                }
                catch
                {
                }
                if (str == null)
                {
                    str = "ConnectionString";
                }
                return(str.Trim());
            }
        public SqlDataSourceQuery GetInsertQuery()
        {
            if (!this.CanAutoGenerateQueries())
            {
                return(null);
            }
            List <Parameter> parameters = new List <Parameter>();
            StringBuilder    builder    = new StringBuilder("INSERT INTO ");

            builder.Append(this.GetTableName());
            List <SqlDataSourceColumnData> effectiveColumns = this.GetEffectiveColumns();
            StringBuilder builder2 = new StringBuilder();
            StringBuilder builder3 = new StringBuilder();
            bool          flag     = true;

            foreach (SqlDataSourceColumnData data in effectiveColumns)
            {
                if (!data.Column.Identity)
                {
                    if (!flag)
                    {
                        builder2.Append(", ");
                        builder3.Append(", ");
                    }
                    builder2.Append(data.EscapedName);
                    builder3.Append(data.ParameterPlaceholder);
                    DbProviderFactory dbProviderFactory = SqlDataSourceDesigner.GetDbProviderFactory(this.DesignerDataConnection.ProviderName);
                    parameters.Add(SqlDataSourceDesigner.CreateParameter(dbProviderFactory, data.WebParameterName, data.Column.DataType));
                    flag = false;
                }
            }
            if (flag)
            {
                return(null);
            }
            builder.Append(" (");
            builder.Append(builder2.ToString());
            builder.Append(") VALUES (");
            builder.Append(builder3.ToString());
            builder.Append(")");
            return(new SqlDataSourceQuery(builder.ToString(), SqlDataSourceCommandType.Text, parameters));
        }
Beispiel #22
0
        public SqlDataSourceQueryEditorForm(IServiceProvider serviceProvider, SqlDataSourceDesigner sqlDataSourceDesigner, string providerName, string connectionString, DataSourceOperation operation, SqlDataSourceCommandType commandType, string command, IList originalParameters) : base(serviceProvider)
        {
            this._sqlDataSourceDesigner = sqlDataSourceDesigner;
            this.InitializeComponent();
            this.InitializeUI();
            if (string.IsNullOrEmpty(providerName))
            {
                providerName = "System.Data.SqlClient";
            }
            this._dataConnection      = new DesignerDataConnection(string.Empty, providerName, connectionString);
            this._commandType         = commandType;
            this._commandTextBox.Text = command;
            this._originalParameters  = originalParameters;
            string str = Enum.GetName(typeof(DataSourceOperation), operation).ToUpperInvariant();

            this._commandLabel.Text = System.Design.SR.GetString("SqlDataSourceQueryEditorForm_CommandLabel", new object[] { str });
            ArrayList dest = new ArrayList(originalParameters.Count);

            sqlDataSourceDesigner.CopyList(originalParameters, dest);
            this._parameterEditorUserControl.AddParameters((Parameter[])dest.ToArray(typeof(Parameter)));
            this._commandTextBox.Select(0, 0);
            switch (operation)
            {
            case DataSourceOperation.Delete:
                this._queryBuilderMode = QueryBuilderMode.Delete;
                return;

            case DataSourceOperation.Insert:
                this._queryBuilderMode = QueryBuilderMode.Insert;
                return;

            case DataSourceOperation.Select:
                this._queryBuilderMode = QueryBuilderMode.Select;
                return;

            case DataSourceOperation.Update:
                this._queryBuilderMode = QueryBuilderMode.Update;
                return;
            }
        }
        internal static string EscapeObjectName(DesignerDataConnection connection, string objectName)
        {
            string str  = "[";
            string str2 = "]";

            try
            {
                DbProviderFactory dbProviderFactory = SqlDataSourceDesigner.GetDbProviderFactory(connection.ProviderName);
                DbCommandBuilder  builder           = dbProviderFactory.CreateCommandBuilder();
                if (dbProviderFactory == OracleClientFactory.Instance)
                {
                    str = str2 = "\"";
                }
                builder.QuotePrefix = str;
                builder.QuoteSuffix = str2;
                return(builder.QuoteIdentifier(objectName));
            }
            catch (Exception)
            {
                return(str + objectName + str2);
            }
        }
        public SqlDataSourceQueryEditorForm(IServiceProvider serviceProvider, SqlDataSourceDesigner sqlDataSourceDesigner, string providerName, string connectionString, DataSourceOperation operation, SqlDataSourceCommandType commandType, string command, IList originalParameters) : base(serviceProvider)
        {
            this._sqlDataSourceDesigner = sqlDataSourceDesigner;
            this.InitializeComponent();
            this.InitializeUI();
            if (string.IsNullOrEmpty(providerName))
            {
                providerName = "System.Data.SqlClient";
            }
            this._dataConnection = new DesignerDataConnection(string.Empty, providerName, connectionString);
            this._commandType = commandType;
            this._commandTextBox.Text = command;
            this._originalParameters = originalParameters;
            string str = Enum.GetName(typeof(DataSourceOperation), operation).ToUpperInvariant();
            this._commandLabel.Text = System.Design.SR.GetString("SqlDataSourceQueryEditorForm_CommandLabel", new object[] { str });
            ArrayList dest = new ArrayList(originalParameters.Count);
            sqlDataSourceDesigner.CopyList(originalParameters, dest);
            this._parameterEditorUserControl.AddParameters((Parameter[]) dest.ToArray(typeof(Parameter)));
            this._commandTextBox.Select(0, 0);
            switch (operation)
            {
                case DataSourceOperation.Delete:
                    this._queryBuilderMode = QueryBuilderMode.Delete;
                    return;

                case DataSourceOperation.Insert:
                    this._queryBuilderMode = QueryBuilderMode.Insert;
                    return;

                case DataSourceOperation.Select:
                    this._queryBuilderMode = QueryBuilderMode.Select;
                    return;

                case DataSourceOperation.Update:
                    this._queryBuilderMode = QueryBuilderMode.Update;
                    return;
            }
        }
        public void SetConnectionInfo(DesignerDataConnection dataConnection)
        {
            this._dataConnection = dataConnection;
            this.ResetUI();
            bool saveConfiguredConnectionState = this._sqlDataSourceDesigner.SaveConfiguredConnectionState;
            DesignerDataConnection connection  = new DesignerDataConnection(string.Empty, this._sqlDataSourceDesigner.ProviderName, this._sqlDataSourceDesigner.ConnectionString);

            if (SqlDataSourceDesigner.ConnectionsEqual(dataConnection, connection))
            {
                if (!saveConfiguredConnectionState)
                {
                    this._saveCheckBox.Checked = false;
                }
                if (this._nameTextBox.Text.Length == 0)
                {
                    this._nameTextBox.Text = this.CreateDefaultConnectionName();
                }
            }
            else
            {
                this._nameTextBox.Text = this.CreateDefaultConnectionName();
            }
        }
 internal static void PersistConnectionSettings(SqlDataSource sqlDataSource, SqlDataSourceDesigner sqlDataSourceDesigner, DesignerDataConnection dataConnection)
 {
     if (dataConnection.IsConfigured)
     {
         ExpressionBindingCollection expressions = sqlDataSource.Expressions;
         PropertyDescriptor descriptor = TypeDescriptor.GetProperties(sqlDataSource)["ProviderName"];
         descriptor.ResetValue(sqlDataSource);
         if (dataConnection.ProviderName == "System.Data.SqlClient")
         {
             expressions.Remove(descriptor.Name);
         }
         else
         {
             expressions.Add(new ExpressionBinding(descriptor.Name, descriptor.PropertyType, "ConnectionStrings", dataConnection.Name + ".ProviderName"));
         }
         descriptor = TypeDescriptor.GetProperties(sqlDataSource)["ConnectionString"];
         descriptor.ResetValue(sqlDataSource);
         expressions.Add(new ExpressionBinding(descriptor.Name, descriptor.PropertyType, "ConnectionStrings", dataConnection.Name));
     }
     else
     {
         PropertyDescriptor descriptor2;
         if (sqlDataSource.ProviderName != dataConnection.ProviderName)
         {
             descriptor2 = TypeDescriptor.GetProperties(sqlDataSource)["ProviderName"];
             descriptor2.ResetValue(sqlDataSource);
             descriptor2.SetValue(sqlDataSource, dataConnection.ProviderName);
         }
         if (sqlDataSource.ConnectionString != dataConnection.ConnectionString)
         {
             descriptor2 = TypeDescriptor.GetProperties(sqlDataSource)["ConnectionString"];
             descriptor2.ResetValue(sqlDataSource);
             descriptor2.SetValue(sqlDataSource, dataConnection.ConnectionString);
         }
     }
 }
 public SqlDataSourceConfigureSortForm(SqlDataSourceDesigner sqlDataSourceDesigner, SqlDataSourceTableQuery tableQuery) : base(sqlDataSourceDesigner.Component.Site)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this._tableQuery = tableQuery.Clone();
     this.InitializeComponent();
     this.InitializeUI();
     Cursor current = Cursor.Current;
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         this._loadingClauses = true;
         this._fieldComboBox1.Items.Add(new ColumnItem(null));
         this._fieldComboBox2.Items.Add(new ColumnItem(null));
         this._fieldComboBox3.Items.Add(new ColumnItem(null));
         foreach (DesignerDataColumn column in this._tableQuery.DesignerDataTable.Columns)
         {
             this._fieldComboBox1.Items.Add(new ColumnItem(column));
             this._fieldComboBox2.Items.Add(new ColumnItem(column));
             this._fieldComboBox3.Items.Add(new ColumnItem(column));
         }
         this._fieldComboBox1.InvalidateDropDownWidth();
         this._fieldComboBox2.InvalidateDropDownWidth();
         this._fieldComboBox3.InvalidateDropDownWidth();
         this._sortByGroupBox2.Enabled = false;
         this._sortByGroupBox3.Enabled = false;
         this._sortDirectionPanel1.Enabled = false;
         this._sortDirectionPanel2.Enabled = false;
         this._sortDirectionPanel3.Enabled = false;
         this._sortAscendingRadioButton1.Checked = true;
         this._sortAscendingRadioButton2.Checked = true;
         this._sortAscendingRadioButton3.Checked = true;
         if (this._tableQuery.OrderClauses.Count >= 1)
         {
             SqlDataSourceOrderClause clause = this._tableQuery.OrderClauses[0];
             this.SelectFieldItem(this._fieldComboBox1, clause.DesignerDataColumn);
             this._sortAscendingRadioButton1.Checked = !clause.IsDescending;
             this._sortDescendingRadioButton1.Checked = clause.IsDescending;
             if (this._tableQuery.OrderClauses.Count >= 2)
             {
                 SqlDataSourceOrderClause clause2 = this._tableQuery.OrderClauses[1];
                 this.SelectFieldItem(this._fieldComboBox2, clause2.DesignerDataColumn);
                 this._sortAscendingRadioButton2.Checked = !clause2.IsDescending;
                 this._sortDescendingRadioButton2.Checked = clause2.IsDescending;
                 if (this._tableQuery.OrderClauses.Count >= 3)
                 {
                     SqlDataSourceOrderClause clause3 = this._tableQuery.OrderClauses[2];
                     this.SelectFieldItem(this._fieldComboBox3, clause3.DesignerDataColumn);
                     this._sortAscendingRadioButton3.Checked = !clause3.IsDescending;
                     this._sortDescendingRadioButton3.Checked = clause3.IsDescending;
                 }
             }
         }
         this._loadingClauses = false;
         this.UpdateOrderClauses();
         this.UpdatePreview();
     }
     finally
     {
         Cursor.Current = current;
     }
 }
 public void SetCommandData(SqlDataSourceDesigner sqlDataSourceDesigner, QueryBuilderMode editorMode)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this._editorMode = editorMode;
     this._queryBuilderButton.Enabled = false;
     IServiceProvider site = this._sqlDataSourceDesigner.Component.Site;
     if (site != null)
     {
         this._dataEnvironment = (IDataEnvironment) site.GetService(typeof(IDataEnvironment));
     }
 }
Beispiel #29
0
 public SqlDesignerDataSourceView(SqlDataSourceDesigner owner, string viewName) : base(owner, viewName)
 {
     this._owner = owner;
 }
Beispiel #30
0
 public SqlDataSourceSummaryPanel(SqlDataSourceDesigner sqlDataSourceDesigner)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this.InitializeComponent();
     this.InitializeUI();
 }
 protected SqlDataSourceConnectionPanel(SqlDataSourceDesigner sqlDataSourceDesigner)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
 }
Beispiel #32
0
        public SqlDataSourceConfigureSortForm(SqlDataSourceDesigner sqlDataSourceDesigner, SqlDataSourceTableQuery tableQuery) : base(sqlDataSourceDesigner.Component.Site)
        {
            this._sqlDataSourceDesigner = sqlDataSourceDesigner;
            this._tableQuery            = tableQuery.Clone();
            this.InitializeComponent();
            this.InitializeUI();
            Cursor current = Cursor.Current;

            try
            {
                Cursor.Current       = Cursors.WaitCursor;
                this._loadingClauses = true;
                this._fieldComboBox1.Items.Add(new ColumnItem(null));
                this._fieldComboBox2.Items.Add(new ColumnItem(null));
                this._fieldComboBox3.Items.Add(new ColumnItem(null));
                foreach (DesignerDataColumn column in this._tableQuery.DesignerDataTable.Columns)
                {
                    this._fieldComboBox1.Items.Add(new ColumnItem(column));
                    this._fieldComboBox2.Items.Add(new ColumnItem(column));
                    this._fieldComboBox3.Items.Add(new ColumnItem(column));
                }
                this._fieldComboBox1.InvalidateDropDownWidth();
                this._fieldComboBox2.InvalidateDropDownWidth();
                this._fieldComboBox3.InvalidateDropDownWidth();
                this._sortByGroupBox2.Enabled           = false;
                this._sortByGroupBox3.Enabled           = false;
                this._sortDirectionPanel1.Enabled       = false;
                this._sortDirectionPanel2.Enabled       = false;
                this._sortDirectionPanel3.Enabled       = false;
                this._sortAscendingRadioButton1.Checked = true;
                this._sortAscendingRadioButton2.Checked = true;
                this._sortAscendingRadioButton3.Checked = true;
                if (this._tableQuery.OrderClauses.Count >= 1)
                {
                    SqlDataSourceOrderClause clause = this._tableQuery.OrderClauses[0];
                    this.SelectFieldItem(this._fieldComboBox1, clause.DesignerDataColumn);
                    this._sortAscendingRadioButton1.Checked  = !clause.IsDescending;
                    this._sortDescendingRadioButton1.Checked = clause.IsDescending;
                    if (this._tableQuery.OrderClauses.Count >= 2)
                    {
                        SqlDataSourceOrderClause clause2 = this._tableQuery.OrderClauses[1];
                        this.SelectFieldItem(this._fieldComboBox2, clause2.DesignerDataColumn);
                        this._sortAscendingRadioButton2.Checked  = !clause2.IsDescending;
                        this._sortDescendingRadioButton2.Checked = clause2.IsDescending;
                        if (this._tableQuery.OrderClauses.Count >= 3)
                        {
                            SqlDataSourceOrderClause clause3 = this._tableQuery.OrderClauses[2];
                            this.SelectFieldItem(this._fieldComboBox3, clause3.DesignerDataColumn);
                            this._sortAscendingRadioButton3.Checked  = !clause3.IsDescending;
                            this._sortDescendingRadioButton3.Checked = clause3.IsDescending;
                        }
                    }
                }
                this._loadingClauses = false;
                this.UpdateOrderClauses();
                this.UpdatePreview();
            }
            finally
            {
                Cursor.Current = current;
            }
        }
        public SqlDataSourceQuery GetQuery()
        {
            SqlDataSourceQuery query;
            Cursor             current = Cursor.Current;

            try
            {
                DbProviderFactory dbProviderFactory;
                Cursor.Current = Cursors.WaitCursor;
                if (this._sqlRadioButton.Checked)
                {
                    SqlDataSourceCommandType text;
                    ICollection is2;
                    if (this._commandTextBox.Text.Trim().Length <= 0)
                    {
                        return(new SqlDataSourceQuery(string.Empty, SqlDataSourceCommandType.Text, new Parameter[0]));
                    }
                    if (string.Equals(this._commandTextBox.Text, this._originalCommand, StringComparison.OrdinalIgnoreCase))
                    {
                        text = this._commandType;
                    }
                    else
                    {
                        text = SqlDataSourceCommandType.Text;
                    }
                    dbProviderFactory = SqlDataSourceDesigner.GetDbProviderFactory(this._dataConnection.ProviderName);
                    if ((this._editorMode == QueryBuilderMode.Select) || SqlDataSourceDesigner.SupportsNamedParameters(dbProviderFactory))
                    {
                        Parameter[] c = this._sqlDataSourceDesigner.InferParameterNames(this._dataConnection, this._commandTextBox.Text, text);
                        if (c == null)
                        {
                            return(null);
                        }
                        ArrayList list = new ArrayList(c);
                        is2 = this.MergeParameters(this._parameters, list, SqlDataSourceDesigner.SupportsNamedParameters(dbProviderFactory));
                    }
                    else
                    {
                        is2 = this._parameters;
                    }
                    return(new SqlDataSourceQuery(this._commandTextBox.Text, text, is2));
                }
                StoredProcedureItem selectedItem = this._storedProcedureComboBox.SelectedItem as StoredProcedureItem;
                if (selectedItem == null)
                {
                    return(new SqlDataSourceQuery(string.Empty, SqlDataSourceCommandType.Text, new Parameter[0]));
                }
                ArrayList   newParameters = new ArrayList();
                ICollection is3           = null;
                try
                {
                    is3 = selectedItem.DesignerDataStoredProcedure.Parameters;
                }
                catch (Exception exception)
                {
                    UIServiceHelper.ShowError(this._sqlDataSourceDesigner.Component.Site, exception, System.Design.SR.GetString("SqlDataSourceCustomCommandEditor_CouldNotGetStoredProcedureSchema"));
                    return(null);
                }
                dbProviderFactory = SqlDataSourceDesigner.GetDbProviderFactory(this._dataConnection.ProviderName);
                if ((is3 != null) && (is3.Count > 0))
                {
                    foreach (DesignerDataParameter parameter in is3)
                    {
                        string    name       = SqlDataSourceDesigner.StripParameterPrefix(parameter.Name);
                        Parameter parameter2 = SqlDataSourceDesigner.CreateParameter(dbProviderFactory, name, parameter.DataType);
                        parameter2.Direction = parameter.Direction;
                        newParameters.Add(parameter2);
                    }
                }
                ICollection parameters = this.MergeParameters(this._parameters, newParameters, SqlDataSourceDesigner.SupportsNamedParameters(dbProviderFactory));
                query = new SqlDataSourceQuery(selectedItem.DesignerDataStoredProcedure.Name, SqlDataSourceCommandType.StoredProcedure, parameters);
            }
            finally
            {
                Cursor.Current = current;
            }
            return(query);
        }
        private bool EditQueryChangeCallback(object context)
        {
            SqlDataSource         first   = (SqlDataSource)((Pair)context).First;
            DataSourceOperation   second  = (DataSourceOperation)((Pair)context).Second;
            IServiceProvider      site    = first.Site;
            IDesignerHost         service = (IDesignerHost)site.GetService(typeof(IDesignerHost));
            SqlDataSourceDesigner sqlDataSourceDesigner = (SqlDataSourceDesigner)service.GetDesigner(first);
            ParameterCollection   originalParameters    = null;
            string command = string.Empty;
            SqlDataSourceCommandType text = SqlDataSourceCommandType.Text;

            switch (second)
            {
            case DataSourceOperation.Delete:
                originalParameters = first.DeleteParameters;
                command            = first.DeleteCommand;
                text = first.DeleteCommandType;
                break;

            case DataSourceOperation.Insert:
                originalParameters = first.InsertParameters;
                command            = first.InsertCommand;
                text = first.InsertCommandType;
                break;

            case DataSourceOperation.Select:
                originalParameters = first.SelectParameters;
                command            = first.SelectCommand;
                text = first.SelectCommandType;
                break;

            case DataSourceOperation.Update:
                originalParameters = first.UpdateParameters;
                command            = first.UpdateCommand;
                text = first.UpdateCommandType;
                break;
            }
            SqlDataSourceQueryEditorForm form = new SqlDataSourceQueryEditorForm(site, sqlDataSourceDesigner, first.ProviderName, sqlDataSourceDesigner.ConnectionString, second, text, command, originalParameters);

            if (UIServiceHelper.ShowDialog(site, form) != DialogResult.OK)
            {
                return(false);
            }
            PropertyDescriptor descriptor = null;

            switch (second)
            {
            case DataSourceOperation.Delete:
                descriptor = TypeDescriptor.GetProperties(first)["DeleteCommand"];
                break;

            case DataSourceOperation.Insert:
                descriptor = TypeDescriptor.GetProperties(first)["InsertCommand"];
                break;

            case DataSourceOperation.Select:
                descriptor = TypeDescriptor.GetProperties(first)["SelectCommand"];
                break;

            case DataSourceOperation.Update:
                descriptor = TypeDescriptor.GetProperties(first)["UpdateCommand"];
                break;
            }
            if (descriptor != null)
            {
                descriptor.ResetValue(first);
                descriptor.SetValue(first, form.Command);
            }
            return(true);
        }
 protected SqlDataSourceConnectionPanel(SqlDataSourceDesigner sqlDataSourceDesigner)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
 }
 public SqlDataSourceSummaryPanel(SqlDataSourceDesigner sqlDataSourceDesigner)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this.InitializeComponent();
     this.InitializeUI();
 }
 public SqlDataSourceConfigureSelectPanel(SqlDataSourceDesigner sqlDataSourceDesigner)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this.InitializeComponent();
     this.InitializeUI();
 }
Beispiel #38
0
        private void OnTestQueryButtonClick(object sender, EventArgs e)
        {
            ParameterCollection parameters = new ParameterCollection();

            foreach (Parameter parameter in this._selectQuery.Parameters)
            {
                if (parameter.DbType == DbType.Object)
                {
                    parameters.Add(new Parameter(parameter.Name, parameter.Type, parameter.DefaultValue));
                }
                else
                {
                    parameters.Add(new Parameter(parameter.Name, parameter.DbType, parameter.DefaultValue));
                }
            }
            if (parameters.Count > 0)
            {
                SqlDataSourceParameterValueEditorForm form = new SqlDataSourceParameterValueEditorForm(base.ServiceProvider, parameters);
                if (UIServiceHelper.ShowDialog(base.ServiceProvider, form) == DialogResult.Cancel)
                {
                    return;
                }
            }
            this._resultsGridView.DataSource = null;
            DbCommand command = null;
            Cursor    current = Cursor.Current;

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                DbProviderFactory dbProviderFactory    = SqlDataSourceDesigner.GetDbProviderFactory(this._dataConnection.ProviderName);
                DbConnection      designTimeConnection = null;
                try
                {
                    designTimeConnection = SqlDataSourceDesigner.GetDesignTimeConnection(base.ServiceProvider, this._dataConnection);
                }
                catch (Exception exception)
                {
                    if (designTimeConnection == null)
                    {
                        UIServiceHelper.ShowError(base.ServiceProvider, exception, System.Design.SR.GetString("SqlDataSourceSummaryPanel_CouldNotCreateConnection"));
                        return;
                    }
                }
                if (designTimeConnection == null)
                {
                    UIServiceHelper.ShowError(base.ServiceProvider, System.Design.SR.GetString("SqlDataSourceSummaryPanel_CouldNotCreateConnection"));
                }
                else
                {
                    command = this._sqlDataSourceDesigner.BuildSelectCommand(dbProviderFactory, designTimeConnection, this._selectQuery.Command, parameters, this._selectQuery.CommandType);
                    DbDataAdapter adapter = SqlDataSourceDesigner.CreateDataAdapter(dbProviderFactory, command);
                    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet);
                    if (dataSet.Tables.Count == 0)
                    {
                        UIServiceHelper.ShowError(base.ServiceProvider, System.Design.SR.GetString("SqlDataSourceSummaryPanel_CannotExecuteQueryNoTables"));
                    }
                    else
                    {
                        this._resultsGridView.DataSource = dataSet.Tables[0];
                        foreach (DataGridViewColumn column in this._resultsGridView.Columns)
                        {
                            column.SortMode = DataGridViewColumnSortMode.NotSortable;
                        }
                        this._resultsGridView.AutoResizeColumnHeadersHeight();
                        this._resultsGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
                    }
                }
            }
            catch (Exception exception2)
            {
                UIServiceHelper.ShowError(base.ServiceProvider, exception2, System.Design.SR.GetString("SqlDataSourceSummaryPanel_CannotExecuteQuery"));
            }
            finally
            {
                if ((command != null) && (command.Connection.State == ConnectionState.Open))
                {
                    command.Connection.Close();
                }
                Cursor.Current = current;
            }
        }
 public SqlDesignerDataSourceView(SqlDataSourceDesigner owner, string viewName)
     : base(owner, viewName)
 {
     this._owner = owner;
 }
Beispiel #40
0
 private void OnInferParametersButtonClick(object sender, EventArgs e)
 {
     if (this._commandTextBox.Text.Trim().Length == 0)
     {
         UIServiceHelper.ShowError(base.ServiceProvider, System.Design.SR.GetString("SqlDataSourceQueryEditorForm_InferNeedsCommand"));
     }
     else
     {
         Parameter[] parameterArray = this._sqlDataSourceDesigner.InferParameterNames(this._dataConnection, this._commandTextBox.Text, this._commandType);
         if (parameterArray != null)
         {
             Parameter[]      parameters = this._parameterEditorUserControl.GetParameters();
             StringCollection strings    = new StringCollection();
             foreach (Parameter parameter in parameters)
             {
                 strings.Add(parameter.Name);
             }
             bool flag = true;
             try
             {
                 flag = SqlDataSourceDesigner.SupportsNamedParameters(SqlDataSourceDesigner.GetDbProviderFactory(this._dataConnection.ProviderName));
             }
             catch
             {
             }
             if (flag)
             {
                 List <Parameter> list = new List <Parameter>();
                 foreach (Parameter parameter2 in parameterArray)
                 {
                     if (!strings.Contains(parameter2.Name))
                     {
                         list.Add(parameter2);
                     }
                     else
                     {
                         strings.Remove(parameter2.Name);
                     }
                 }
                 this._parameterEditorUserControl.AddParameters(list.ToArray());
             }
             else
             {
                 List <Parameter> list2 = new List <Parameter>();
                 foreach (Parameter parameter3 in parameterArray)
                 {
                     list2.Add(parameter3);
                 }
                 foreach (Parameter parameter4 in parameters)
                 {
                     Parameter item = null;
                     foreach (Parameter parameter6 in list2)
                     {
                         if (parameter6.Direction == parameter4.Direction)
                         {
                             item = parameter6;
                             break;
                         }
                     }
                     if (item != null)
                     {
                         list2.Remove(item);
                     }
                 }
                 this._parameterEditorUserControl.AddParameters(list2.ToArray());
             }
         }
     }
 }