Beispiel #1
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 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);
 }
 private static CommandType GetCommandType(SqlDataSourceCommandType commandType)
 {
     if (commandType == SqlDataSourceCommandType.Text)
     {
         return(CommandType.Text);
     }
     return(CommandType.StoredProcedure);
 }
Beispiel #4
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;
            }
        }
        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 SetQuery(SqlDataSourceQuery query)
 {
     this._storedProcedureComboBox.SelectedIndex = -1;
     if (this._storedProcedures != null)
     {
         foreach (StoredProcedureItem item in this._storedProcedureComboBox.Items)
         {
             if (item.DesignerDataStoredProcedure.Name == query.Command)
             {
                 this._storedProcedureComboBox.SelectedItem = item;
                 break;
             }
         }
     }
     if (this._storedProcedureComboBox.SelectedIndex != -1)
     {
         this._sqlRadioButton.Checked             = false;
         this._storedProcedureRadioButton.Checked = true;
     }
     else
     {
         this._sqlRadioButton.Checked             = true;
         this._storedProcedureRadioButton.Checked = false;
         if (this._storedProcedureComboBox.Items.Count > 0)
         {
             this._storedProcedureComboBox.SelectedIndex = 0;
         }
     }
     if (!this._queryInitialized)
     {
         this._commandTextBox.Text = query.Command;
         this._originalCommand     = query.Command;
         this._commandType         = query.CommandType;
         this._parameters          = query.Parameters;
         this._queryInitialized    = true;
     }
     this.UpdateEnabledState();
 }
 public SqlDataSourceQuery(string command, SqlDataSourceCommandType commandType, ICollection parameters)
 {
     this._command = command;
     this._commandType = commandType;
     this._parameters = parameters;
 }
 public void SetQuery(SqlDataSourceQuery query)
 {
     this._storedProcedureComboBox.SelectedIndex = -1;
     if (this._storedProcedures != null)
     {
         foreach (StoredProcedureItem item in this._storedProcedureComboBox.Items)
         {
             if (item.DesignerDataStoredProcedure.Name == query.Command)
             {
                 this._storedProcedureComboBox.SelectedItem = item;
                 break;
             }
         }
     }
     if (this._storedProcedureComboBox.SelectedIndex != -1)
     {
         this._sqlRadioButton.Checked = false;
         this._storedProcedureRadioButton.Checked = true;
     }
     else
     {
         this._sqlRadioButton.Checked = true;
         this._storedProcedureRadioButton.Checked = false;
         if (this._storedProcedureComboBox.Items.Count > 0)
         {
             this._storedProcedureComboBox.SelectedIndex = 0;
         }
     }
     if (!this._queryInitialized)
     {
         this._commandTextBox.Text = query.Command;
         this._originalCommand = query.Command;
         this._commandType = query.CommandType;
         this._parameters = query.Parameters;
         this._queryInitialized = true;
     }
     this.UpdateEnabledState();
 }
 /// <devdoc>
 /// Converts a SqlDataSourceCommandType to a System.Data.CommandType.
 /// </devdoc>
 private static CommandType GetCommandType(SqlDataSourceCommandType commandType) {
     if (commandType == SqlDataSourceCommandType.Text) {
         return CommandType.Text;
     }
     return CommandType.StoredProcedure;
 }
 protected internal virtual Parameter[] InferParameterNames(DesignerDataConnection connection, string commandText, SqlDataSourceCommandType commandType)
 {
     Parameter[] parameterArray2;
     Cursor current = Cursor.Current;
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         if (commandText.Length == 0)
         {
             UIServiceHelper.ShowError(this.SqlDataSource.Site, System.Design.SR.GetString("SqlDataSourceDesigner_NoCommand"));
             return null;
         }
         if (commandType == SqlDataSourceCommandType.Text)
         {
             return SqlDataSourceParameterParser.ParseCommandText(connection.ProviderName, commandText);
         }
         DbProviderFactory dbProviderFactory = GetDbProviderFactory(connection.ProviderName);
         DbConnection designTimeConnection = null;
         try
         {
             designTimeConnection = GetDesignTimeConnection(base.Component.Site, connection);
         }
         catch (Exception exception)
         {
             if (designTimeConnection == null)
             {
                 UIServiceHelper.ShowError(this.SqlDataSource.Site, exception, System.Design.SR.GetString("SqlDataSourceDesigner_CouldNotCreateConnection"));
                 return null;
             }
         }
         if (designTimeConnection == null)
         {
             UIServiceHelper.ShowError(this.SqlDataSource.Site, System.Design.SR.GetString("SqlDataSourceDesigner_CouldNotCreateConnection"));
             return null;
         }
         DbCommand command = this.BuildSelectCommand(dbProviderFactory, designTimeConnection, commandText, null, commandType);
         command.CommandType = CommandType.StoredProcedure;
         try
         {
             this.DeriveParameters(connection.ProviderName, command);
         }
         catch (Exception exception2)
         {
             UIServiceHelper.ShowError(this.SqlDataSource.Site, System.Design.SR.GetString("SqlDataSourceDesigner_InferStoredProcedureError", new object[] { exception2.Message }));
             return null;
         }
         finally
         {
             if (command.Connection.State == ConnectionState.Open)
             {
                 designTimeConnection.Close();
             }
         }
         int count = command.Parameters.Count;
         Parameter[] parameterArray = new Parameter[count];
         for (int i = 0; i < count; i++)
         {
             IDataParameter parameter = command.Parameters[i];
             if (parameter != null)
             {
                 string name = StripParameterPrefix(parameter.ParameterName);
                 parameterArray[i] = CreateParameter(dbProviderFactory, name, parameter.DbType);
                 parameterArray[i].Direction = parameter.Direction;
             }
         }
         parameterArray2 = parameterArray;
     }
     finally
     {
         Cursor.Current = current;
     }
     return parameterArray2;
 }
        internal DbCommand BuildSelectCommand(DbProviderFactory factory, DbConnection connection, string commandText, ParameterCollection parameters, SqlDataSourceCommandType commandType)
        {
            DbCommand command = CreateCommand(factory, commandText, connection);

            if ((parameters != null) && (parameters.Count > 0))
            {
                IOrderedDictionary values          = parameters.GetValues(null, null);
                string             parameterPrefix = GetParameterPrefix(factory);
                for (int i = 0; i < parameters.Count; i++)
                {
                    Parameter   parameter  = parameters[i];
                    DbParameter parameter2 = CreateParameter(factory);
                    parameter2.ParameterName = parameterPrefix + parameter.Name;
                    if (parameter.DbType != DbType.Object)
                    {
                        SqlParameter parameter3 = parameter2 as SqlParameter;
                        if (parameter3 == null)
                        {
                            parameter2.DbType = parameter.DbType;
                        }
                        else if (parameter.DbType == DbType.Date)
                        {
                            parameter3.SqlDbType = SqlDbType.Date;
                        }
                        else if (parameter.DbType == DbType.Time)
                        {
                            parameter3.SqlDbType = SqlDbType.Time;
                        }
                        else
                        {
                            parameter2.DbType = parameter.DbType;
                        }
                    }
                    else
                    {
                        if ((parameter.Type != TypeCode.Empty) && (parameter.Type != TypeCode.DBNull))
                        {
                            parameter2.DbType = parameter.GetDatabaseType();
                        }
                        if ((parameter.Type == TypeCode.Empty) && ProviderRequiresDbTypeSet(factory))
                        {
                            parameter2.DbType = DbType.Object;
                        }
                    }
                    parameter2.Value = values[i];
                    if (parameter2.Value == null)
                    {
                        parameter2.Value = DBNull.Value;
                    }
                    if (Parameter.ConvertDbTypeToTypeCode(parameter2.DbType) == TypeCode.String)
                    {
                        if ((parameter2.Value is string) && (parameter2.Value != null))
                        {
                            parameter2.Size = ((string)parameter2.Value).Length;
                        }
                        else
                        {
                            parameter2.Size = 1;
                        }
                    }
                    command.Parameters.Add(parameter2);
                }
            }
            command.CommandType = GetCommandType(commandType);
            return(command);
        }
        internal bool RefreshSchema(DesignerDataConnection connection, string commandText, SqlDataSourceCommandType commandType, ParameterCollection parameters, bool preferSilent)
        {
            IServiceProvider site    = this.SqlDataSource.Site;
            DbCommand        command = null;

            try
            {
                DbProviderFactory dbProviderFactory    = GetDbProviderFactory(connection.ProviderName);
                DbConnection      designTimeConnection = GetDesignTimeConnection(base.Component.Site, connection);
                if (designTimeConnection == null)
                {
                    if (!preferSilent)
                    {
                        UIServiceHelper.ShowError(this.SqlDataSource.Site, System.Design.SR.GetString("SqlDataSourceDesigner_CouldNotCreateConnection"));
                    }
                    return(false);
                }
                command = this.BuildSelectCommand(dbProviderFactory, designTimeConnection, commandText, parameters, commandType);
                DbDataAdapter adapter = CreateDataAdapter(dbProviderFactory, command);
                adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                DataSet dataSet = new DataSet();
                adapter.FillSchema(dataSet, SchemaType.Source, "DefaultView");
                DataTable schemaTable = dataSet.Tables["DefaultView"];
                if (schemaTable == null)
                {
                    if (!preferSilent)
                    {
                        UIServiceHelper.ShowError(site, System.Design.SR.GetString("SqlDataSourceDesigner_CannotGetSchema"));
                    }
                    return(false);
                }
                this.SaveSchema(connection, commandText, schemaTable);
                return(true);
            }
            catch (Exception exception)
            {
                if (!preferSilent)
                {
                    UIServiceHelper.ShowError(site, exception, System.Design.SR.GetString("SqlDataSourceDesigner_CannotGetSchema"));
                }
            }
            finally
            {
                if ((command != null) && (command.Connection.State == ConnectionState.Open))
                {
                    command.Connection.Close();
                }
            }
            return(false);
        }
        protected internal virtual Parameter[] InferParameterNames(DesignerDataConnection connection, string commandText, SqlDataSourceCommandType commandType)
        {
            Parameter[] parameterArray2;
            Cursor      current = Cursor.Current;

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (commandText.Length == 0)
                {
                    UIServiceHelper.ShowError(this.SqlDataSource.Site, System.Design.SR.GetString("SqlDataSourceDesigner_NoCommand"));
                    return(null);
                }
                if (commandType == SqlDataSourceCommandType.Text)
                {
                    return(SqlDataSourceParameterParser.ParseCommandText(connection.ProviderName, commandText));
                }
                DbProviderFactory dbProviderFactory    = GetDbProviderFactory(connection.ProviderName);
                DbConnection      designTimeConnection = null;
                try
                {
                    designTimeConnection = GetDesignTimeConnection(base.Component.Site, connection);
                }
                catch (Exception exception)
                {
                    if (designTimeConnection == null)
                    {
                        UIServiceHelper.ShowError(this.SqlDataSource.Site, exception, System.Design.SR.GetString("SqlDataSourceDesigner_CouldNotCreateConnection"));
                        return(null);
                    }
                }
                if (designTimeConnection == null)
                {
                    UIServiceHelper.ShowError(this.SqlDataSource.Site, System.Design.SR.GetString("SqlDataSourceDesigner_CouldNotCreateConnection"));
                    return(null);
                }
                DbCommand command = this.BuildSelectCommand(dbProviderFactory, designTimeConnection, commandText, null, commandType);
                command.CommandType = CommandType.StoredProcedure;
                try
                {
                    this.DeriveParameters(connection.ProviderName, command);
                }
                catch (Exception exception2)
                {
                    UIServiceHelper.ShowError(this.SqlDataSource.Site, System.Design.SR.GetString("SqlDataSourceDesigner_InferStoredProcedureError", new object[] { exception2.Message }));
                    return(null);
                }
                finally
                {
                    if (command.Connection.State == ConnectionState.Open)
                    {
                        designTimeConnection.Close();
                    }
                }
                int         count          = command.Parameters.Count;
                Parameter[] parameterArray = new Parameter[count];
                for (int i = 0; i < count; i++)
                {
                    IDataParameter parameter = command.Parameters[i];
                    if (parameter != null)
                    {
                        string name = StripParameterPrefix(parameter.ParameterName);
                        parameterArray[i]           = CreateParameter(dbProviderFactory, name, parameter.DbType);
                        parameterArray[i].Direction = parameter.Direction;
                    }
                }
                parameterArray2 = parameterArray;
            }
            finally
            {
                Cursor.Current = current;
            }
            return(parameterArray2);
        }
 internal DbCommand BuildSelectCommand(DbProviderFactory factory, DbConnection connection, string commandText, ParameterCollection parameters, SqlDataSourceCommandType commandType)
 {
     DbCommand command = CreateCommand(factory, commandText, connection);
     if ((parameters != null) && (parameters.Count > 0))
     {
         IOrderedDictionary values = parameters.GetValues(null, null);
         string parameterPrefix = GetParameterPrefix(factory);
         for (int i = 0; i < parameters.Count; i++)
         {
             Parameter parameter = parameters[i];
             DbParameter parameter2 = CreateParameter(factory);
             parameter2.ParameterName = parameterPrefix + parameter.Name;
             if (parameter.DbType != DbType.Object)
             {
                 SqlParameter parameter3 = parameter2 as SqlParameter;
                 if (parameter3 == null)
                 {
                     parameter2.DbType = parameter.DbType;
                 }
                 else if (parameter.DbType == DbType.Date)
                 {
                     parameter3.SqlDbType = SqlDbType.Date;
                 }
                 else if (parameter.DbType == DbType.Time)
                 {
                     parameter3.SqlDbType = SqlDbType.Time;
                 }
                 else
                 {
                     parameter2.DbType = parameter.DbType;
                 }
             }
             else
             {
                 if ((parameter.Type != TypeCode.Empty) && (parameter.Type != TypeCode.DBNull))
                 {
                     parameter2.DbType = parameter.GetDatabaseType();
                 }
                 if ((parameter.Type == TypeCode.Empty) && ProviderRequiresDbTypeSet(factory))
                 {
                     parameter2.DbType = DbType.Object;
                 }
             }
             parameter2.Value = values[i];
             if (parameter2.Value == null)
             {
                 parameter2.Value = DBNull.Value;
             }
             if (Parameter.ConvertDbTypeToTypeCode(parameter2.DbType) == TypeCode.String)
             {
                 if ((parameter2.Value is string) && (parameter2.Value != null))
                 {
                     parameter2.Size = ((string) parameter2.Value).Length;
                 }
                 else
                 {
                     parameter2.Size = 1;
                 }
             }
             command.Parameters.Add(parameter2);
         }
     }
     command.CommandType = GetCommandType(commandType);
     return command;
 }
 internal bool RefreshSchema(DesignerDataConnection connection, string commandText, SqlDataSourceCommandType commandType, ParameterCollection parameters, bool preferSilent)
 {
     IServiceProvider site = this.SqlDataSource.Site;
     DbCommand command = null;
     try
     {
         DbProviderFactory dbProviderFactory = GetDbProviderFactory(connection.ProviderName);
         DbConnection designTimeConnection = GetDesignTimeConnection(base.Component.Site, connection);
         if (designTimeConnection == null)
         {
             if (!preferSilent)
             {
                 UIServiceHelper.ShowError(this.SqlDataSource.Site, System.Design.SR.GetString("SqlDataSourceDesigner_CouldNotCreateConnection"));
             }
             return false;
         }
         command = this.BuildSelectCommand(dbProviderFactory, designTimeConnection, commandText, parameters, commandType);
         DbDataAdapter adapter = CreateDataAdapter(dbProviderFactory, command);
         adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
         DataSet dataSet = new DataSet();
         adapter.FillSchema(dataSet, SchemaType.Source, "DefaultView");
         DataTable schemaTable = dataSet.Tables["DefaultView"];
         if (schemaTable == null)
         {
             if (!preferSilent)
             {
                 UIServiceHelper.ShowError(site, System.Design.SR.GetString("SqlDataSourceDesigner_CannotGetSchema"));
             }
             return false;
         }
         this.SaveSchema(connection, commandText, schemaTable);
         return true;
     }
     catch (Exception exception)
     {
         if (!preferSilent)
         {
             UIServiceHelper.ShowError(site, exception, System.Design.SR.GetString("SqlDataSourceDesigner_CannotGetSchema"));
         }
     }
     finally
     {
         if ((command != null) && (command.Connection.State == ConnectionState.Open))
         {
             command.Connection.Close();
         }
     }
     return false;
 }
        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);
        }
 public SqlDataSourceQuery(string command, SqlDataSourceCommandType commandType, ICollection parameters)
 {
     this._command     = command;
     this._commandType = commandType;
     this._parameters  = parameters;
 }