Ejemplo n.º 1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (ConfigXML.AccessAllow(NTT.Web.Core.Security.Cryto.MD5(this.txt_conf.Text)))
     {
         ConfigXML.BuildXMLFile("config.xml", this.Txt_Server.Text, this.txt_db.Text, this.txt_uid.Text, this.txt_pwd.Text);
         this.lb_mess.Text = "Đã lưu cấu hình";
     }
     else
     {
         this.lb_mess.Text = "Mật khẩu cấu hình không đúng";
     }
 }
Ejemplo n.º 2
0
    protected void btnTest_Click(object sender, EventArgs e)
    {
        if (ConfigXML.AccessAllow(NTT.Web.Core.Security.Cryto.MD5(this.txt_conf.Text)))
        {
            //ConfigXML.BuildConfigFile("tmpdbconfig.xml", this.Txt_Server.Text, this.txt_db.Text, this.txt_uid.Text, this.txt_pwd.Text);

            StringBuilder sb = new StringBuilder();
            sb.Append("Server=").Append(this.Txt_Server.Text).Append(";");
            sb.Append("Database=").Append(this.txt_db.Text).Append(";");
            //sb.Append("Integrated Security=SSPI;");
            sb.Append("uid=").Append(this.txt_uid.Text).Append(";");
            sb.Append("pwd=").Append(this.txt_pwd.Text).Append(";");
            sb.Append("Connect Timeout=30");

            string     connection_string = sb.ToString();
            DataObject con = new DataObject(connection_string, false);
            try
            {
                if (con.TestConnection())
                {
                    this.lb_mess.Text = "Kết nối thành công";
                }
                else
                {
                    this.lb_mess.Text = "Không thể kết nối!!!";
                }
            }
            catch (Exception E)
            {
                this.lb_mess.Text = E.Message;
            }
        }
        else
        {
            this.lb_mess.Text = "Mật khẩu cấu hình không đúng";
        }
    }