top of page

 

 

Base de datos de Alumnos sin GAMA:

 

 

 

 

CREATE TABLE Alumnos

(

 

 

nombre varchar(20) NOT NULL,

telefono varchar(20) NOT NULL,

nota1 varchar(10) NOT NULL,

nota2 varchar(10) NOT NULL,

nota_final varchar(10) NOT NULL,

 

 

 

 

CONSTRAINT PK_Alumnos PRIMARY KEY (nombre)

 

)

 

 

 

CREATE PROCEDURE sp_ActualizarAlumnos

(

@nombre VARCHAR(20),

@telefono VARCHAR(20),

@nota1 VARCHAR(10),

@nota2 VARCHAR(10),

@nota_final VARCHAR(10)

 

 

 

)

 

 

 

AS

 

 

BEGIN

UPDATE Alumnos

SET nombre = @nombre

,telefono = @telefono

,nota1 = @nota1

,nota2 = @nota2

,nota_final = @nota_final

 

 

 

WHERE nombre = @nombre

END

 

 

 

CREATE PROCEDURE sp_DeleteAlumnos

(

@nombre VARCHAR(20)

)

AS

BEGIN

DELETE FROM Alumnos

WHERE nombre = @nombre

END

 

 

 

 

 

CREATE PROCEDURE sp_InsertarAlumnos

(

@nombre VARCHAR(20),

@telefono VARCHAR(20),

@nota1 VARCHAR(10),

@nota2 VARCHAR(10),

@nota_final VARCHAR(10)

 

 

)

AS

BEGIN

INSERT INTO Alumnos

(nombre

,telefono

,nota1

,nota2

,nota_final)

 

 

 

VALUES

(@nombre

,@telefono

,@nota1

,@nota2

,@nota_final)

 

END

 

 

 

CREATE PROCEDURE sp_ListarAlumnosPorNombre

(

@nombre VARCHAR(20)

)

AS

BEGIN

SELECT nombre

,telefono

,nota1

,nota2

,nota_final

 

 

FROM Alumnos

WHERE nombre = @nombre

END

 

 

 

 

CREATE PROCEDURE sp_ListarAlumnos

AS

BEGIN

SELECT nombre,

telefono,

nota1,

nota2,

nota_final

 

FROM Alumnos

END

 

 

 

 

 

 

 

 

 

 

EN CASO DE QUE GAMA DL NO FUNCIONE USAR ESTA:

 

 

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Data;

using System.Data.SqlClient;

using EXAMEN.Entidad;

 

namespace Examen.Data

{

    public class GamaDL

    {

        public List<GamaBE> ListarGamas()

        {

            ConexionDL conexion = new ConexionDL();

            try

            {

                SqlCommand cmd = new SqlCommand("sp_ListarGamas", conexion.Con);

                cmd.CommandType = CommandType.StoredProcedure;

                conexion.AbrirConexionBD();

                SqlDataReader reader = cmd.ExecuteReader();

                List<GamaBE> listaGamas = new List<GamaBE>();

                while (reader.Read())

                {

                    GamaBE gama = new GamaBE();

                    gama.IdGama = Convert.ToInt32(reader["IdGama"]);

                    gama.DescripcionGama = Convert.ToString(reader["Descripcion"]);

                    gama.Precio = Convert.ToDecimal(reader["Precio"]);

                    listaGamas.Add(gama);

                }

                return listaGamas;

            }

            catch (Exception ex)

            {

                throw new Exception(ex.Message);

            }

            finally

            {

                conexion.CerrarConexionBD();

            }

        }

    }

}

 

 

 

 

Facebook

  • Facebook Classic
  • c-youtube

YouTube

Become a Fan

bottom of page