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

Показать описание
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
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
Комментарии