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

preview_player
Показать описание
Just follow these 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-
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

-- 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)
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-PC\ROWSHAN_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

------
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.

Visit my page in Facebook
------

More Tags

Рекомендации по теме
Комментарии
Автор

This is really great!. Your code is much clear to understand as beginner. Thanks

SwiftLearn
Автор

Man i really appreciate this tutorial
Thank you for your efforts,
May Allah help you

daviddavid-mxif
Автор

Hiii thank you so much you made my day i have it perfectly by seeing this.😇thank you god bless you

kichunew
Автор

simple sweet and concise good work bro

amanmathur
Автор

Very good video thank you !! Question how do you automatically clear the text box after insert ?

philmorefoster
Автор

Is there any video where you don't have to type id in textbox you have set id as autoincrement then how to identify which row to update

sonaliparab
Автор

im getting error
The request for procedure 'Bookings' failed because 'Bookings' is a table object
what does that mean?

ridarafiiq
Автор

you must mute the back music to avoid distraction !!!

KhurramShahzad-qtkj
Автор

Muy bueno, me gustaría que hagas el actualizar un registro del seleccionando un registro dentro de el y que llene las cajas de texto para modificar y me gustaría que sacaras mas videos sobre la elaboración de un sistema completo por favor bendiciones

alexabc
Автор

How to check if the ID already exists.?

kuldeepmohanty