Ejemplo n.º 1
0
        protected void btn_Test_Click(object sender, EventArgs e)
        {
            fileLocation = txt_FileLocation.Text;
            password     = txt_password.Text;

            if (PasswordRequired.Checked)
            {
                connectionString = "Data Source =" + fileLocation + "; Provider = Microsoft.ACE.OLEDB.12.0; Jet OLEDB:Database Password="******";";
            }
            else
            {
                connectionString = "Data Source =" + fileLocation + "; Provider = Microsoft.ACE.OLEDB.12.0;";
            }


            if (TestAccessConnection(connectionString))
            {
                lbl_result.Text              = "Connection Successful";
                btn_Next.Visible             = true;
                Panel1.Visible               = true; Panel2.Visible = true;
                TableDropDownList.DataSource = GetTableNames(connectionString);
                TableDropDownList.DataBind();
            }
            else
            {
                lbl_result.Text = "Please Check Data";
            }
        }
        protected void btn_Test_Click(object sender, EventArgs e)
        {
            btn_Next.Visible = false;

            if (!string.IsNullOrEmpty(txt_DataSource.Text))
            {
                dataSource = txt_DataSource.Text;
            }

            if (!string.IsNullOrEmpty(txt_dbName.Text))
            {
                dBName = txt_dbName.Text;
            }

            if (PasswordRequired.Checked)
            {
                if (!string.IsNullOrEmpty(txt_username.Text))
                {
                    username = txt_username.Text;
                }
                if (!string.IsNullOrEmpty(txt_password.Text))
                {
                    password = txt_password.Text;
                }

                connectionString = "Data Source = " + dataSource + "; User Id =" + dBName + ";Password = "******";";
            }
            else
            {
                connectionString = "Data Source =" + dataSource + "; Integrated Security = yes;";
            }

            if (TestSQLConnection(connectionString))
            {
                lbl_result.Text              = "Connection Successful";
                btn_Next.Visible             = true;
                Panel1.Visible               = true; Panel2.Visible = true;
                TableDropDownList.DataSource = GetTableNames();
                TableDropDownList.DataBind();
            }
            else
            {
                lbl_result.Text = "Please Check Data";
            }
        }
        protected void btn_Test_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txt_DatabaseName.Text))
            {
                dbName = txt_DatabaseName.Text;
            }

            if (!string.IsNullOrEmpty(txt_ServerName.Text))
            {
                serverName = txt_ServerName.Text;
            }

            if (PasswordRequired.Checked)
            {
                if (!string.IsNullOrEmpty(txt_username.Text))
                {
                    username = txt_username.Text;
                }
                if (!string.IsNullOrEmpty(txt_password.Text))
                {
                    password = txt_password.Text;
                }

                connectionString = "Server=" + serverName + ";Database=" + dbName + ";User Id=" + username + ";Password="******"Server=" + serverName + ";Database=" + dbName + ";Trusted_Connection=True;";
            }

            if (TestSQLConnection(connectionString))
            {
                lbl_result.Text              = "Connection Successful";
                btn_Next.Visible             = true;
                Panel1.Visible               = true; Panel2.Visible = true;
                TableDropDownList.DataSource = GetTableNames();
                TableDropDownList.DataBind();
            }
            else
            {
                lbl_result.Text = "Please Check Data";
            }
        }