create stored procedure for insert record in database using asp.net
A) Create Database: Student_Record
B) Create Table : Student_Details
C) Create Store Procedure FOR INSERT RECORD IN SQL SERVER
CREATE procedure [dbo].[InsertRecord]
@Student_Name nvarchar(50),
@Student_Address nvarchar(50),
@Student_Course nvarchar(50),
@Student_fee int
as
begin
insert into Student_Details (Std_Name,Std_Address, Std_Course, Std_Fee)
values(@Student_Name, @Student_Address, @Student_Course,@Student_fee)
SqlConnection sqlcon = new SqlConnection("Data Source=CSLODHI-PC\\SQLEXPRESS;Initial Catalog=Student_Record;Integrated Security=True");
string pname = "InsertRecord";
sqlcon.Open();
SqlCommand cmd = new SqlCommand(pname, sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Student_Name", TextBox2.Text);
cmd.Parameters.AddWithValue("@Student_Address",TextBox3.Text);
cmd.Parameters.AddWithValue("@Student_Course", TextBox4.Text);
cmd.Parameters.AddWithValue("@Student_Fee",Convert.ToInt32(TextBox5.Text));
cmd.ExecuteNonQuery();
Response.Write("Record Successfully Inserted");
sqlcon.Close();
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
Reviewed by JOB ORIENTED STUDY ACADEMY
on
January 10, 2021
Rating:


No comments: