Basic example of Stored procedure
Hai,
In Asp.net page
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["cnn"].ToString());
con.Open();
SqlCommand cmd = new SqlCommand("storedetails", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@name", txtname.Text.Trim());
cmd.Parameters.AddWithValue("@class", txtclass.Text.Trim());
cmd.Parameters.AddWithValue("@mark", txtmark.Text.Trim());
cmd.ExecuteNonQuery();
Query to create stored procedure
CREATE PROCEDURE storedetails
@name varchar(30) = NULL,
@class varchar(5) = NULL,
@mark int = NULL
AS
BEGIN
SET NOCOUNT ON;
insert into student values(@name,@class,@mark)
insert into result values(@name,@class)
return
OnError: --If error exit gracefully
Return
END
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home