You are on page 1of 2

using

using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Web;
System.Web.UI;
System.Web.UI.WebControls;
System.Data;
System.Data.SqlClient;

public partial class notasalumno : System.Web.UI.Page


{
public string cadena = @"Data Source=ALEXPC\SQLEXPRESS;Initial Catalog=inji;Integrated
Security=True";

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)


{
Panel1.Visible = true;
string NIE = TextBox1.Text;
SqlConnection con = new SqlConnection(cadena);
string ade = "select * from Alumnos where Alumnos.NIE='" + TextBox1.Text + "' ";
SqlDataAdapter ad = new SqlDataAdapter("select Nombre_Materia,
Periodo1,Periodo2,Periodo3,Periodo4,Nota_Final from Notas where Notas.NIE='" + NIE + "'",
con);
DataSet ds = new DataSet();
ad.Fill(ds, "Notas");
SqlCommand comando = new SqlCommand(ade, con);
con.Open();
SqlDataReader leer = comando.ExecuteReader();
GridView1.DataSource = ds;
GridView1.DataBind();
if (leer.Read() == true)
{
Label1.Text = leer["Nombres"].ToString();
Label2.Text = leer["Apellidos"].ToString();
Label3.Text = leer["Grado"].ToString();
Label4.Text = leer["Seccion"].ToString();
Label5.Text = leer["Fecha_Nacimiento"].ToString();
Label6.Text = leer["Genero"].ToString();
Label7.Text = leer["Opcion"].ToString();
Label8.Text = leer["Encargado"].ToString();
Label9.Text = leer["NIE"].ToString();
}
else
{
Label1.Text = "Error";
Label2.Text = "Error";
Label3.Text = "Error";

Label4.Text
Label5.Text
Label6.Text
Label7.Text
Label8.Text
Label9.Text

=
=
=
=
=
=

"Error";
"Error";
"Error";
"Error";
"Error";
"Error";

TextBox1.Text = "";
con.Close();

You might also like