Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnectionStringBuilder ConBuilder = new SqlConnectionStringBuilder();

            if (txtDataSource.Text.Trim().Length == 0)
            {
                clsUtility.ShowInfoMessage("Enter Data Source.", "Connection String Builder.");
                return;
            }

            else if (txtInitialCatalog.Text.Trim().Length == 0)
            {
                clsUtility.ShowInfoMessage("Enter Initial Catalog.(Database name)", "Connection String Builder.");
                return;
            }

            else if (comboBox1.SelectedIndex == -1)
            {
                clsUtility.ShowInfoMessage("Select Integrated Security.", "Connection String Builder.");
                return;
            }
            else if (comboBox1.SelectedIndex == 0 || comboBox1.SelectedIndex == 2)
            {
                if (txtUserID.Text.Trim().Length == 0)
                {
                    clsUtility.ShowInfoMessage("Enter User ID.", "Connection String Builder.");
                    return;
                }

                if (txtPassword.Text.Trim().Length == 0)
                {
                    clsUtility.ShowInfoMessage("Enter Password.", "Connection String Builder.");
                    return;
                }
            }

            ConBuilder.DataSource     = txtDataSource.Text;
            ConBuilder.InitialCatalog = txtInitialCatalog.Text;

            if (comboBox1.SelectedIndex == 1)
            {
                ConBuilder.IntegratedSecurity = Convert.ToBoolean(comboBox1.SelectedItem);
            }
            else
            {
                ConBuilder.UserID   = txtUserID.Text;
                ConBuilder.Password = txtPassword.Text;
            }

            if (checkBox1.Checked)
            {
                ConBuilder.MultipleActiveResultSets = checkBox1.Checked;
            }

            if (chkPooling.Checked)
            {
                ConBuilder.Pooling = chkPooling.Checked;
            }

            if (chkPooling.Checked)
            {
                if (txtMaxPoolSize.Text.Trim().Length == 0)
                {
                    clsUtility.ShowInfoMessage("Enter MaxPool Size.", "Connection String Builder.");
                    return;
                }
                if (txtMinPoolSize.Text.Trim().Length == 0)
                {
                    clsUtility.ShowInfoMessage("Enter MinPool Size.", "Connection String Builder.");
                    return;
                }
                ConBuilder.MaxPoolSize = Convert.ToInt32(txtMaxPoolSize.Text);
                ConBuilder.MinPoolSize = Convert.ToInt32(txtMinPoolSize.Text);
            }

            ConnectingString Obj = new ConnectingString();

            Obj.txtDataSource.Text = ConBuilder.ConnectionString;
            Obj.ShowDialog();
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            ConnectingString Obj = new ConnectingString();

            Obj.ShowDialog();
        }