0% found this document useful (0 votes)
213 views

Using Using Using Using Using Using Using Using Public Partial Class Public String

This document defines a C# class called "notasalumno" that handles retrieving and displaying student grade data from a SQL database. It contains methods for connecting to the database using a connection string, running queries to get student information and grades based on a student ID number, binding the results to interface elements like labels and a grid view, and displaying errors if the student is not found.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
213 views

Using Using Using Using Using Using Using Using Public Partial Class Public String

This document defines a C# class called "notasalumno" that handles retrieving and displaying student grade data from a SQL database. It contains methods for connecting to the database using a connection string, running queries to get student information and grades based on a student ID number, binding the results to interface elements like labels and a grid view, and displaying errors if the student is not found.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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