Ejemplo n.º 1
0
        protected void btnInsertar_Click(object sender, EventArgs e)
        {
            EstudianteDLL myconexion = new EstudianteDLL();

            Session["USER"] = txtusuario.Text;
            Session["PASS"] = txtpassword.Text;


            try
            {
                myconexion.conectar(txtusuario.Text, txtpassword.Text);

                System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('Felicidades se conecto');", true);
                Response.Redirect("main.aspx");
            }
            catch (Exception ex)
            {
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('error');", true);
                Response.Write("<script language=javascript>console.log('" + ex.ToString() + "'); </script>");
                //throw;
            }
        }
Ejemplo n.º 2
0
        protected void Unnamed2_Click(object sender, EventArgs e)
        {
            EstudianteDLL manejodb = new EstudianteDLL();

            string Query_Crear = "create database " + txtbasedatos.Text;

            string user = Session["USER"].ToString();
            string pass = Session["PASS"].ToString();

            try
            {
                manejodb.conectar(user, pass);
                manejodb.EjecutarSQL(Query_Crear);
                manejodb.Desconectar();
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('Exito se creo');", true);
            }
            catch (Exception ex)
            {
                //System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('No se creo');", true);
                Response.Write("<script language=javascript>console.log('" + ex.ToString() + "'); </script>");
                //throw;
            }
        }