You are on page 1of 2

Procedimiento almacenado

USE[alumnosutsc] GO CREATE PROCEDURE [sp_delAlumno] (@Matricula[int] ) AS delete [alumnosutsc].[dbo].[alumno] where Matricula=@Matricula Codigo del programa en ASP .NET C# using using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.Data.SqlClient;

namespace WebApplication17 { public partial class WebForm2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if(TextBox1.Text=="") { Label2.Text="Llenar el Campo Matricula"; return; } string strSQLDelete = "[sp_delAlumno]"; SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = "data source=localhost;" + "Initial Catalog=alumnosutsc;Integrated Security=SSPI"; SqlCommand deleteCommand = new SqlCommand(strSQLDelete, myConnection); deleteCommand.CommandType = CommandType.StoredProcedure; SqlParameter param;

param.Int). try { myConnection.ExecuteNonQuery().param = deleteCommand. } if (deleted > 0) { Label2. Label2.Direction = ParameterDirection. deleted = deleteCommand.ToString() + "registro eliminado".Text = "".Open(). } catch (Exception err) { Label2.Input. } finally { myConnection. EventArgs e) { TextBox1.Text += err.Text = "error no se encontro la matricula". param. } } } .Text = "error al borrar registro".Parameters. SqlDbType.Add("@Matricula".ToInt32(TextBox1.Message. } protected void Button2_Click(object sender. int deleted = 0.Text). } else Label2.Value = Convert.Text = deleted.Close().