How to use stored procedure
Go to server explorer -> right click on stored procedure ->ADD
NEW STORED PROCEDURE
CREATE PROCEDURE
dbo.StoredProcedure2
/*
(
@parameter1 int = 5,
@parameter2 datatype OUTPUT
)
*/
AS
/* SET NOCOUNT ON */
RETURN
ALTER PROCEDURE dbo.StoredProcedure1
(
@roll1 int,
@name1 varchar(500) //VARIBLE TO
FETCH DATABASE
)
AS
insert into stu values(@roll1,@name1)
RETURN
How to use procedure in
asp.net form
using System.Data.SqlClient;
using System.Data;
protected void Button1_Click(object sender, EventArgs e)
{
string cs=@path”;
cn = new
SqlConnection(cs);
cn.Open();
//SqlCommand cmd = new SqlCommand("procedure name", cn);
SqlCommand cmd = new
SqlCommand("StoredProcedure1", cn);
cmd.CommandType =
CommandType.StoredProcedure;
//rool1
, name1 is a
stored procedure variable
cmd.Parameters.AddWithValue("roll1", TextBox1.Text);
cmd.Parameters.AddWithValue("name1",
TextBox2.Text);
cmd.ExecuteNonQuery();
}
No comments:
Post a Comment