Insert,Update, Delete using Angular js in ASP.NET MVC
In this Post We Will Explain About is Insert,Update, Delete using Angular js in ASP.NET MVC With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Angular js with ASP.NET MVC Insert,Update, Delete Example
In this post we will show you Best way to implement angularjs database connection example, hear for insert update delete in asp.net using angularjs with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
AngularJS Ajax $http – Asp.net with SQL example
In this AngularJS Ajax $http example we will see how to save data, delete row and display the data in html table using Asp.net with SQL using simple AngularJS $http request
CS Page:
//include ASP.net namespace... using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Script.Serialization; using System.Data.SqlClient; using System.Data; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } [System.Web.Services.WebMethod()] public static void Save(string ClientName) { using (SqlConnection con = new SqlConnection(@"data source=localhost\sqlexpress;user id=sa; password=live24u@123; database=livedb;")) { using (SqlCommand con = new SqlCommand()) { con.Connection = con; con.CommandText = "insert into clientMaster (ClientName) values (@ClientName);"; con.Parameters.AddWithValue("@ClientName", ClientName); con.Open(); con.ExecuteNonQuery(); con.Close(); } } } [System.Web.Services.WebMethod()] public static void Delete(int ClientID) { using (SqlConnection con = new SqlConnection(@"data source=localhost\sqlexpress;user id=sa; password=123; database=Sample;")) { using (SqlCommand con = new SqlCommand()) { con.Connection = con; con.CommandText = "update clientMaster set IsActive=0 where ClientID=@ClientID;"; con.Parameters.AddWithValue("@ClientID", ClientID); con.Open(); con.ExecuteNonQuery(); con.Close(); } } } [System.Web.Services.WebMethod()] public static ListGetList() { List names = new List (); DataSet ds = new DataSet(); using (SqlConnection con = new SqlConnection(@"data source=localhost\sqlexpress;user id=sa; password=123; database=Sample;")) { using (SqlCommand con = new SqlCommand()) { con.Connection = con; con.CommandText = "select ClientID,ClientName from clientMaster where IsActive=1;"; using (SqlDataAdapter da = new SqlDataAdapter(con)) { da.Fill(ds); } } } if (ds != null && ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) names.Add(new Names(int.Parse(dr["ClientID"].ToString()), dr["ClientName"].ToString())); } return names; } } public class Names { public int ClientID; public string ClientName; public Names(int _ClientID, string _ClientName) { ClientID = _ClientID; ClientName = _ClientName; } }
ASPX Page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
SQL Query to create table:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[clientMaster]( [ClientID] [int] IDENTITY(1,1) NOT NULL, [ClientName] [varchar](50) NOT NULL, [IsActive] [bit] NOT NULL CONSTRAINT [DF_clientMaster_IsActive] DEFAULT ((1)), CONSTRAINT [PK_clientMaster] PRIMARY KEY CLUSTERED ( [ClientID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO
You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example
I hope you have Got What is Angular js with ASP.NET MVC Insert,Update, Delete And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.