Complete CRUD Operation in Asp.Net C# Using Stored Procedure | ProgrammingGeek



This is Asp.Net tutorial. In this tutorial you can learn complete CRUD(Create, Retrieve, Update, Delete) operation in Asp.Net c# with MS SQL Server using Stored Procedure.
Just follow this steps-
1. Create a new Asp.Net project.
2. Design the project with Label, TextBox, DropDownList, RadioButton and button control.
3. Create database and table in SQL Server.
4. Create Stored Procedure in SQL Server database.
5. Connect sql server with visual studio.
6. Write code to execute CRUD operation in Asp.Net c#.

Prerequisites.
You should have installed sql server and visual studio. you can use sql server integrated with visual studio instead of SQL Server management studio.

This tutorial also covered-
1. Creating new asp.net project in visual studio 2015.
2. Creating sql server database, table and stored procedure in sql server.
3. Creating method in Asp.Net c#.
4. Calling method in button click_event and Page_Load event.
5. Getting connectionSting and connecting with SQL Server using Server Explorer.
6. Initializing connectionSting in all event.
7. How to load data in GridView using SQL Stored Procedure.

Complete CRUD Operation in Asp.Net C# With SQL Server Step By Step
https://youtu.be/I5cWkoMeQIY

— SQL
create proc ProductSetup_SP
@ProductID int,
@ItemName nvarchar(50),
@Specification nvarchar(150),
@Unit nvarchar(30),
@Status nvarchar(30),
@CreationDate datetime
as
begin
Insert into ProductSetup_Tab (ProductID,ItemName, Specification,Unit,Status,CreationDate)
values (@ProductID,@ItemName,@Specification,@Unit,@Status,@CreationDate)
end

exec ProductSetup_SP 1001,’Laptop’, ‘Dell Core i 7’, ‘PCS’, ‘Running’, ‘1/1/2021’

create proc ProductList_SP
as
begin
select * from ProductSetup_Tab
end

–Code
SqlConnection con = new SqlConnection(@”Data Source=ROWSHAN-PCROWSHAN_PC;Initial Catalog=MyTest_DB;User ID=sa;Password=DBPassword”);
protected void Button1_Click(object sender, EventArgs e)
{
int productid = int.Parse(TextBox1.Text);
string iname = TextBox2.Text, specification = TextBox3.Text, unit = DropDownList1.SelectedValue, status = RadioButtonList1.SelectedValue;
DateTime cdate = DateTime.Parse(TextBox4.Text);
con.Open();
SqlCommand co = new SqlCommand(“exec ProductSetup_SP ‘”+productid+ “‘,'” + iname + “‘,'” + specification + “‘,'” + unit + “‘,'” + status + “‘,'” + cdate + “‘”, con);
co.ExecuteNonQuery();
con.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), “script”, “alert(‘Successfully Inserted.’);”,true);
GetProductList();
}

void GetProductList()
{
SqlCommand co = new SqlCommand(“exec ProductList_SP”, con);
SqlDataAdapter sd = new SqlDataAdapter(co);
DataTable dt = new DataTable();
sd.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}

Asp.Net With SQL Playlist
https://www.youtube.com/watch?v=I5cWkoMeQIY&list=PL4Qls_AA7vWKIs_wRT2MS5TgocHJsjM9U

——
This channel covers all the programming tutorial related with .Net- C#, linq, VB, SQL, Android, HTML, CSS, jQuery, Crystal Report and Microsoft Report.
So, Please subscribe and keep in touch.
https://www.youtube.com/c/ProgrammingGeek

Visit my page in Facebook
https://www.facebook.com/programminggeek7
——

More Tags

programminggeek, crud operation in asp.net web form, crud operation in asp.net c# using stored procedure, crud operation in asp.net core, crud operation in asp.net c#, crud operation in asp.net using stored procedure, crud operation in asp.net c# with sql stored procedure, insert delete update search in asp.net using stored procedure, stored procedure, crud in stored procedure

Comments are closed.