protected void button_Click(object sender, EventArgs e) { using (SqlConnection conexion = Conexion.ObtenerConexion()) { conexion.Open(); string query = "select * from helix_usuario where NOMBRE_USUARIO ='" + txt_user.Text + "' and PASSWORD ='******'"; SqlCommand cmd = new SqlCommand(query, conexion); SqlDataReader Reader1; Reader1 = cmd.ExecuteReader(); if (Reader1.Read()) { //ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('Hola desde el grid');", true); //getInt32 para obtener los valores numericos para comparacion y getValue para obtener el valor de la celda y no comparar if (Reader1.GetInt32(1) == 1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('Bienvenido');", true); perfil = Convert.ToString(Reader1.GetValue(1)); Response.Redirect("/View/Tickets.aspx", true); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('Incorrecto');", true); } } }
private void Group_Project_Load(object sender, EventArgs e) { String str = "Data Source=HAIER-PC\\NIMRASQLSERVER;Initial Catalog=ProjectA;Integrated Security=True"; String query = "select Title from Project;"; SqlConnection con = new SqlConnection(str); SqlCommand cmd = new SqlCommand(query, con); SqlDataReader Reader; con.Open(); Reader = cmd.ExecuteReader(); while (Reader.Read()) { comboBox1.Items.Add(Reader.GetString(0)); } String query1 = "select Id from [Group]"; SqlConnection con1 = new SqlConnection(str); SqlCommand cmd1 = new SqlCommand(query1, con1); SqlDataReader Reader1; con1.Open(); Reader1 = cmd1.ExecuteReader(); while (Reader1.Read()) { comboBox2.Items.Add(Reader1.GetInt32(0)); } }