public string ejecuta(string query) { string devuelt = ""; SqlCommand cm = new SqlCommand(query, c.AbrirConexion()); SqlDataReader dr = cm.ExecuteReader(); while (dr.Read()) { devuelt = dr[0].ToString(); nombre = dr[1].ToString(); } c.CerrarConexion(); return(devuelt); }
protected void Button1_Click(object sender, EventArgs e) { conexion c = new conexion(); if (!string.IsNullOrEmpty(Session["nombre"] + "")) { SqlCommand cm = new SqlCommand("insert into regstro (" + 1 + ",'" + Session["entrada"] + "','" + Session["salida"] + "')", c.AbrirConexion()); cm.ExecuteNonQuery(); Label1.Text = "Registro exitoso"; } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "Información", "alert('Debe Iniciar sesión')", true); } }
protected void registrar(object sender, EventArgs e) { if (!string.IsNullOrEmpty(TextBox6.Text) && !string.IsNullOrEmpty(TextBox1.Text) && !string.IsNullOrEmpty(TextBox2.Text) && !string.IsNullOrEmpty(TextBox3.Text) && !string.IsNullOrEmpty(TextBox4.Text) && !string.IsNullOrEmpty(TextBox5.Text) && !string.IsNullOrEmpty(DropDownList1.Text) && !string.IsNullOrEmpty(TextBox7.Text) && !string.IsNullOrEmpty(TextBox8.Text)) { if (!TextBox7.Text.Equals(TextBox8.Text)) { Label10.Text = "Las contraseñas no coinciden"; return; } conexion c = new conexion(); SqlCommand cm = new SqlCommand("insert into Usuario values('" + TextBox6.Text + "','" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "'," + TextBox4.Text + "," + TextBox5.Text + ",'" + DropDownList1.Text + "','" + TextBox7.Text + "')", c.AbrirConexion()); cm.ExecuteNonQuery(); Label10.Text = "¡Registro Exitoso!"; } else { Label10.Text = "Diligencie todos los campos"; } }