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 SqlDataSourceOrderClause(DesignerDataConnection designerDataConnection, DesignerDataTableBase designerDataTable, System.ComponentModel.Design.Data.DesignerDataColumn designerDataColumn, bool isDescending)
 {
     this._designerDataConnection = designerDataConnection;
     this._designerDataTable = designerDataTable;
     this._designerDataColumn = designerDataColumn;
     this._isDescending = isDescending;
 }
 protected override void OnPanelChanging(WizardPanelChangingEventArgs e)
 {
     base.OnPanelChanging(e);
     if (e.CurrentPanel == this._connectionPanel)
     {
         this._designerDataConnection = this._connectionPanel.DataConnection;
     }
 }
 protected override void OnPanelChanging(WizardPanelChangingEventArgs e)
 {
     base.OnPanelChanging(e);
     if (e.CurrentPanel == this._connectionPanel)
     {
         this._designerDataConnection = this._connectionPanel.DataConnection;
     }
 }
 internal static WizardPanel CreateCommandPanel(SqlDataSourceWizardForm wizard, DesignerDataConnection dataConnection, WizardPanel nextPanel)
 {
     IDataEnvironment service = null;
     IServiceProvider site = wizard.SqlDataSourceDesigner.Component.Site;
     if (site != null)
     {
         service = (IDataEnvironment) site.GetService(typeof(IDataEnvironment));
     }
     bool flag = false;
     if (service != null)
     {
         try
         {
             IDesignerDataSchema connectionSchema = service.GetConnectionSchema(dataConnection);
             if (connectionSchema != null)
             {
                 flag = connectionSchema.SupportsSchemaClass(DesignerDataSchemaClass.Tables);
                 if (flag)
                 {
                     connectionSchema.GetSchemaItems(DesignerDataSchemaClass.Tables);
                 }
                 else
                 {
                     flag = connectionSchema.SupportsSchemaClass(DesignerDataSchemaClass.Views);
                     connectionSchema.GetSchemaItems(DesignerDataSchemaClass.Views);
                 }
             }
         }
         catch (Exception exception)
         {
             UIServiceHelper.ShowError(site, exception, System.Design.SR.GetString("SqlDataSourceConnectionPanel_CouldNotGetConnectionSchema"));
             return null;
         }
     }
     if (nextPanel == null)
     {
         if (flag)
         {
             return wizard.GetConfigureSelectPanel();
         }
         return CreateCustomCommandPanel(wizard, dataConnection);
     }
     if (flag)
     {
         if (nextPanel is SqlDataSourceConfigureSelectPanel)
         {
             return nextPanel;
         }
         return wizard.GetConfigureSelectPanel();
     }
     if (nextPanel is SqlDataSourceCustomCommandPanel)
     {
         return nextPanel;
     }
     return CreateCustomCommandPanel(wizard, dataConnection);
 }
 public SqlDataSourceFilterClause(DesignerDataConnection designerDataConnection, DesignerDataTableBase designerDataTable, System.ComponentModel.Design.Data.DesignerDataColumn designerDataColumn, string operatorFormat, bool isBinary, string value, System.Web.UI.WebControls.Parameter parameter)
 {
     this._designerDataConnection = designerDataConnection;
     this._designerDataTable = designerDataTable;
     this._designerDataColumn = designerDataColumn;
     this._isBinary = isBinary;
     this._operatorFormat = operatorFormat;
     this._value = value;
     this._parameter = parameter;
 }
 protected override void SetProviderName(object instance, DesignerDataConnection connection)
 {
     SqlDataSource component = instance as SqlDataSource;
     if (component != null)
     {
         if (connection.IsConfigured)
         {
             ExpressionEditor expressionEditor = ExpressionEditor.GetExpressionEditor(typeof(ConnectionStringsExpressionBuilder), component.Site);
             if (expressionEditor != null)
             {
                 string expressionPrefix = expressionEditor.ExpressionPrefix;
                 component.Expressions.Add(new ExpressionBinding("ProviderName", typeof(string), expressionPrefix, connection.Name + ".ProviderName"));
             }
         }
         else
         {
             TypeDescriptor.GetProperties(component)["ProviderName"].SetValue(component, connection.ProviderName);
         }
     }
 }
        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;
            }
        }
 private void SetConnectionSettings(DesignerDataConnection conn)
 {
     bool flag = this.SelectConnection(conn);
     string providerName = conn.ProviderName;
     string connectionString = conn.ConnectionString;
     if (!flag && ((providerName.Length > 0) || (connectionString.Length > 0)))
     {
         if (providerName.Length == 0)
         {
             providerName = "System.Data.SqlClient";
         }
         this._connectionsComboBox.Items.Insert(0, new DataConnectionItem(new DesignerDataConnection(conn.Name, providerName, connectionString)));
         this._connectionsComboBox.SelectedIndex = 0;
         this._connectionsComboBox.InvalidateDropDownWidth();
     }
     this._connectionStringTextBox.Text = connectionString;
 }
 public DataConnectionItem(System.ComponentModel.Design.Data.DesignerDataConnection designerDataConnection)
 {
     this._designerDataConnection = designerDataConnection;
 }
 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 DbConnection GetDesignTimeConnection(IServiceProvider serviceProvider, DesignerDataConnection connection)
 {
     if (serviceProvider != null)
     {
         IDataEnvironment service = (IDataEnvironment) serviceProvider.GetService(typeof(IDataEnvironment));
         if (service != null)
         {
             if (string.IsNullOrEmpty(connection.ProviderName))
             {
                 connection = new DesignerDataConnection(connection.Name, "System.Data.SqlClient", connection.ConnectionString);
             }
             return service.GetDesignTimeConnection(connection);
         }
     }
     return null;
 }
 public SqlDataSourceTableQuery(System.ComponentModel.Design.Data.DesignerDataConnection designerDataConnection, DesignerDataTableBase designerDataTable)
 {
     this._designerDataConnection = designerDataConnection;
     this._designerDataTable = designerDataTable;
 }
 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);
     }
 }
 private void SaveSchema(DesignerDataConnection connection, string selectCommand, DataTable schemaTable)
 {
     base.DesignerState["DataSourceSchema"] = schemaTable;
     base.DesignerState["DataSourceSchemaConnectionStringHash"] = connection.ConnectionString.GetHashCode();
     base.DesignerState["DataSourceSchemaProviderName"] = connection.ProviderName;
     base.DesignerState["DataSourceSchemaSelectMethod"] = selectCommand;
 }
 public void SetQueries(DesignerDataConnection dataConnection, SqlDataSourceQuery selectQuery, SqlDataSourceQuery insertQuery, SqlDataSourceQuery updateQuery, SqlDataSourceQuery deleteQuery)
 {
     this._dataConnection = dataConnection;
     this._selectQuery = selectQuery;
     this._insertQuery = insertQuery;
     this._updateQuery = updateQuery;
     this._deleteQuery = deleteQuery;
     this._previewTextBox.Text = this._selectQuery.Command;
     Parameter[] array = new Parameter[this._selectQuery.Parameters.Count];
     this._selectQuery.Parameters.CopyTo(array, 0);
     Parameter[] parameters = MergeParameters(this._parameterEditorUserControl.GetParameters(), array);
     this._parameterEditorUserControl.ClearParameters();
     this._parameterEditorUserControl.AddParameters(parameters);
 }
 public void Start(IWindowsFormsEditorService edSvc, ICollection connections, DesignerDataConnection currentConnection)
 {
     this._edSvc = edSvc;
     base.Items.Clear();
     object obj2 = null;
     foreach (DesignerDataConnection connection in connections)
     {
         DataConnectionItem item = new DataConnectionItem(connection);
         if ((connection.ConnectionString == currentConnection.ConnectionString) && (connection.IsConfigured == currentConnection.IsConfigured))
         {
             obj2 = item;
         }
         base.Items.Add(item);
     }
     base.Items.Add(new DataConnectionItem());
     base.SelectedItem = obj2;
 }
 public SqlDataSourceTableQuery(System.ComponentModel.Design.Data.DesignerDataConnection designerDataConnection, DesignerDataTableBase designerDataTable)
 {
     this._designerDataConnection = designerDataConnection;
     this._designerDataTable      = designerDataTable;
 }
 protected virtual void SetProviderName(object instance, DesignerDataConnection connection)
 {
 }
 public SqlDataSourceColumnData(DesignerDataConnection connection, DesignerDataColumn column, StringCollection usedNames)
 {
     this._connection = connection;
     this._column = column;
     this._usedNames = usedNames;
 }
 public SqlDataSourceColumnData(DesignerDataConnection connection, DesignerDataColumn column) : this(connection, column, null)
 {
 }
 public void SetConnection(DesignerDataConnection dataConnection)
 {
     this._dataConnection = dataConnection;
 }
 protected override void OnVisibleChanged(EventArgs e)
 {
     base.OnVisibleChanged(e);
     if (base.Visible)
     {
         base.ParentWizard.FinishButton.Enabled = false;
         DesignerDataConnection designerDataConnection = ((SqlDataSourceWizardForm) base.ParentWizard).DesignerDataConnection;
         if (!SqlDataSourceDesigner.ConnectionsEqual(this._dataConnection, designerDataConnection))
         {
             this._dataConnection = designerDataConnection;
             this._requiresRefresh = true;
         }
         if (this._requiresRefresh)
         {
             Cursor current = Cursor.Current;
             try
             {
                 Cursor.Current = Cursors.WaitCursor;
                 this._tablesComboBox.SelectedIndex = -1;
                 this._tablesComboBox.Items.Clear();
                 IDataEnvironment dataEnvironment = ((SqlDataSourceWizardForm) base.ParentWizard).DataEnvironment;
                 IDesignerDataSchema connectionSchema = null;
                 if (this._dataConnection != null)
                 {
                     connectionSchema = dataEnvironment.GetConnectionSchema(this._dataConnection);
                 }
                 if (connectionSchema != null)
                 {
                     List<TableItem> list = new List<TableItem>();
                     if (connectionSchema.SupportsSchemaClass(DesignerDataSchemaClass.Tables))
                     {
                         ICollection schemaItems = connectionSchema.GetSchemaItems(DesignerDataSchemaClass.Tables);
                         if (schemaItems != null)
                         {
                             foreach (DesignerDataTable table in schemaItems)
                             {
                                 if (!table.Name.ToLowerInvariant().StartsWith("AspNet_".ToLowerInvariant(), StringComparison.Ordinal))
                                 {
                                     list.Add(new TableItem(table));
                                 }
                             }
                         }
                     }
                     if (connectionSchema.SupportsSchemaClass(DesignerDataSchemaClass.Views))
                     {
                         ICollection is3 = connectionSchema.GetSchemaItems(DesignerDataSchemaClass.Views);
                         if (is3 != null)
                         {
                             foreach (DesignerDataView view in is3)
                             {
                                 list.Add(new TableItem(view));
                             }
                         }
                     }
                     list.Sort((Comparison<TableItem>) ((a, b) => string.Compare(a.DesignerDataTable.Name, b.DesignerDataTable.Name, StringComparison.InvariantCultureIgnoreCase)));
                     this._tablesComboBox.Items.AddRange(list.ToArray());
                     this._tablesComboBox.InvalidateDropDownWidth();
                 }
                 if (this._tablesComboBox.Items.Count > 0)
                 {
                     Hashtable tableQueryState = this._sqlDataSourceDesigner.TableQueryState;
                     bool flag = false;
                     if (tableQueryState != null)
                     {
                         flag = this.LoadTableQueryState(tableQueryState);
                     }
                     if (!flag)
                     {
                         flag = this.LoadParsedSqlState();
                     }
                     if (!flag)
                     {
                         this._tablesComboBox.SelectedIndex = 0;
                         SqlDataSource component = (SqlDataSource) this._sqlDataSourceDesigner.Component;
                         bool flag2 = (((component.SelectCommand.Trim().Length > 0) || (component.InsertCommand.Trim().Length > 0)) || (component.UpdateCommand.Trim().Length > 0)) || (component.DeleteCommand.Trim().Length > 0);
                         this._tableRadioButton.Checked = !flag2;
                         this._customSqlRadioButton.Checked = flag2;
                     }
                     else
                     {
                         this._tableRadioButton.Checked = true;
                         this._customSqlRadioButton.Checked = false;
                     }
                     this._tableRadioButton.Enabled = true;
                 }
                 else
                 {
                     this._customSqlRadioButton.Checked = true;
                     this._tableRadioButton.Enabled = false;
                 }
                 this.UpdatePreview();
             }
             finally
             {
                 Cursor.Current = current;
             }
             this._requiresRefresh = false;
         }
         this.UpdateEnabledUI();
     }
 }
 private void OnQueryBuilderButtonClick(object sender, EventArgs e)
 {
     IServiceProvider site = this._sqlDataSourceDesigner.Component.Site;
     if ((this._dataConnection.ConnectionString != null) && (this._dataConnection.ConnectionString.Trim().Length == 0))
     {
         UIServiceHelper.ShowError(site, System.Design.SR.GetString("SqlDataSourceCustomCommandEditor_NoConnectionString"));
     }
     else
     {
         DesignerDataConnection connection = this._dataConnection;
         if (string.IsNullOrEmpty(this._dataConnection.ProviderName))
         {
             connection = new DesignerDataConnection(this._dataConnection.Name, "System.Data.SqlClient", this._dataConnection.ConnectionString, this._dataConnection.IsConfigured);
         }
         string str = this._dataEnvironment.BuildQuery(this, connection, this._editorMode, this._commandTextBox.Text);
         if ((str != null) && (str.Length > 0))
         {
             this._commandTextBox.Text = str;
             this._commandTextBox.Focus();
             this._commandTextBox.Select(0, 0);
         }
     }
 }
 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;
 }
 public override void RefreshSchema(bool preferSilent)
 {
     try
     {
         this.SuppressDataSourceEvents();
         bool flag = false;
         IServiceProvider site = this.SqlDataSource.Site;
         if (!this.CanRefreshSchema)
         {
             if (!preferSilent)
             {
                 UIServiceHelper.ShowError(site, System.Design.SR.GetString("SqlDataSourceDesigner_RefreshSchemaRequiresSettings"));
             }
         }
         else
         {
             IDataSourceViewSchema schema = this.GetView("DefaultView").Schema;
             bool flag2 = false;
             if (schema == null)
             {
                 this._forceSchemaRetrieval = true;
                 schema = this.GetView("DefaultView").Schema;
                 this._forceSchemaRetrieval = false;
                 flag2 = true;
             }
             DesignerDataConnection connection = new DesignerDataConnection(string.Empty, this.ProviderName, this.ConnectionString);
             if (preferSilent)
             {
                 flag = this.RefreshSchema(connection, this.SelectCommand, this.SqlDataSource.SelectCommandType, this.SqlDataSource.SelectParameters, true);
             }
             else
             {
                 Parameter[] parameterArray = this.InferParameterNames(connection, this.SelectCommand, this.SqlDataSource.SelectCommandType);
                 if (parameterArray == null)
                 {
                     return;
                 }
                 ParameterCollection parameters = new ParameterCollection();
                 ParameterCollection parameters2 = new ParameterCollection();
                 foreach (ICloneable cloneable in this.SqlDataSource.SelectParameters)
                 {
                     parameters2.Add((Parameter) cloneable.Clone());
                 }
                 foreach (Parameter parameter in parameterArray)
                 {
                     if ((parameter.Direction == ParameterDirection.Input) || (parameter.Direction == ParameterDirection.InputOutput))
                     {
                         Parameter parameter2 = parameters2[parameter.Name];
                         if (parameter2 != null)
                         {
                             parameter.DefaultValue = parameter2.DefaultValue;
                             if ((parameter.DbType == DbType.Object) && (parameter.Type == TypeCode.Empty))
                             {
                                 parameter.DbType = parameter2.DbType;
                                 parameter.Type = parameter2.Type;
                             }
                             parameters2.Remove(parameter2);
                         }
                         parameters.Add(parameter);
                     }
                 }
                 if (parameters.Count > 0)
                 {
                     SqlDataSourceRefreshSchemaForm form = new SqlDataSourceRefreshSchemaForm(site, this, parameters);
                     flag = UIServiceHelper.ShowDialog(site, form) == DialogResult.OK;
                 }
                 else
                 {
                     flag = this.RefreshSchema(connection, this.SelectCommand, this.SqlDataSource.SelectCommandType, parameters, false);
                 }
             }
             if (flag)
             {
                 IDataSourceViewSchema schema2 = this.GetView("DefaultView").Schema;
                 if (flag2 && DataSourceDesigner.ViewSchemasEquivalent(schema, schema2))
                 {
                     this.OnDataSourceChanged(EventArgs.Empty);
                 }
                 else if (!DataSourceDesigner.ViewSchemasEquivalent(schema, schema2))
                 {
                     this.OnSchemaRefreshed(EventArgs.Empty);
                 }
             }
         }
     }
     finally
     {
         this.ResumeDataSourceEvents();
     }
 }
 internal DataTable LoadSchema()
 {
     if (!this._forceSchemaRetrieval)
     {
         object obj2 = base.DesignerState["DataSourceSchemaConnectionStringHash"];
         string str = base.DesignerState["DataSourceSchemaProviderName"] as string;
         string a = base.DesignerState["DataSourceSchemaSelectMethod"] as string;
         if (string.IsNullOrEmpty(str))
         {
             str = "System.Data.SqlClient";
         }
         if (string.IsNullOrEmpty(this.ConnectionString))
         {
             return null;
         }
         DesignerDataConnection connection = new DesignerDataConnection(string.Empty, this.ProviderName, this.ConnectionString);
         int hashCode = connection.ConnectionString.GetHashCode();
         string providerName = connection.ProviderName;
         string selectCommand = this.SelectCommand;
         if (string.IsNullOrEmpty(providerName))
         {
             providerName = "System.Data.SqlClient";
         }
         if (((obj2 == null) || (((int) obj2) != hashCode)) || (!string.Equals(str, providerName, StringComparison.OrdinalIgnoreCase) || !string.Equals(a, selectCommand, StringComparison.Ordinal)))
         {
             return null;
         }
     }
     DataTable table = base.DesignerState["DataSourceSchema"] as DataTable;
     if (table != null)
     {
         table.TableName = "DefaultView";
         return table;
     }
     return null;
 }
 internal static bool ConnectionsEqual(DesignerDataConnection connection1, DesignerDataConnection connection2)
 {
     if ((connection1 == null) || (connection2 == null))
     {
         return false;
     }
     if (connection1.ConnectionString != connection2.ConnectionString)
     {
         return false;
     }
     string str = (connection1.ProviderName.Trim().Length == 0) ? "System.Data.SqlClient" : connection1.ProviderName;
     string str2 = (connection2.ProviderName.Trim().Length == 0) ? "System.Data.SqlClient" : connection2.ProviderName;
     return (str == str2);
 }
 public DataConnectionItem(System.ComponentModel.Design.Data.DesignerDataConnection designerDataConnection)
 {
     this._designerDataConnection = designerDataConnection;
 }
Beispiel #30
0
		protected virtual void SetProviderName (object instance, DesignerDataConnection connection)
		{
			throw new NotImplementedException ();
		}
 private void OnNewConnectionButtonClick(object sender, EventArgs e)
 {
     DesignerDataConnection conn = this._dataEnvironment.BuildConnection(this, null);
     if (conn != null)
     {
         if (string.Equals(conn.ProviderName, "Microsoft.SqlServerCe.Client.4.0", StringComparison.OrdinalIgnoreCase))
         {
             conn = new DesignerDataConnection(conn.Name, "System.Data.SqlServerCe.4.0", conn.ConnectionString, conn.IsConfigured);
         }
         if (!this.SelectConnection(conn))
         {
             DataConnectionItem item = new DataConnectionItem(conn);
             this._connectionsComboBox.Items.Add(item);
             this._connectionsComboBox.SelectedItem = item;
             this._connectionsComboBox.InvalidateDropDownWidth();
         }
     }
 }
 private static WizardPanel CreateCustomCommandPanel(SqlDataSourceWizardForm wizard, DesignerDataConnection dataConnection)
 {
     SqlDataSource component = (SqlDataSource) wizard.SqlDataSourceDesigner.Component;
     ArrayList dest = new ArrayList();
     ArrayList list2 = new ArrayList();
     ArrayList list3 = new ArrayList();
     ArrayList list4 = new ArrayList();
     wizard.SqlDataSourceDesigner.CopyList(component.SelectParameters, dest);
     wizard.SqlDataSourceDesigner.CopyList(component.InsertParameters, list2);
     wizard.SqlDataSourceDesigner.CopyList(component.UpdateParameters, list3);
     wizard.SqlDataSourceDesigner.CopyList(component.DeleteParameters, list4);
     SqlDataSourceCustomCommandPanel customCommandPanel = wizard.GetCustomCommandPanel();
     customCommandPanel.SetQueries(dataConnection, new SqlDataSourceQuery(component.SelectCommand, component.SelectCommandType, dest), new SqlDataSourceQuery(component.InsertCommand, component.InsertCommandType, list2), new SqlDataSourceQuery(component.UpdateCommand, component.UpdateCommandType, list3), new SqlDataSourceQuery(component.DeleteCommand, component.DeleteCommandType, list4));
     return customCommandPanel;
 }
 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;
 }