TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Help Needed
NA
13
23.5k
MVC Delete Action Method
Aug 20 2016 3:56 PM
Hi All
Here I am giving my simple stored procedure and Delete Action Method. When I am trying to delete the button it doesn't work.StoredProcedure Is working fine.But when I click delete button it won't delete the record from the table
Create procedure spDeleteEmployee
@Id int
as
Begin
Delete from Employee11 where Id = @Id
End
public void DeleteEmployee(int id)
{
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("spDeleteEmployee", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter paramId = new SqlParameter();
paramId.ParameterName = "@Id";
paramId.Value = id;
cmd.Parameters.Add(paramId);
con.Open();
cmd.ExecuteNonQuery();
}
}
[HttpPost]
public ActionResult DeleteEmployee(int id)
{
EmployeeBusinessLayer employeeBusinessLayer = new EmployeeBusinessLayer();
employeeBusinessLayer.DeleteEmployee(id);
return RedirectToAction("Index");
}
Reply
Answers (
2
)
MYSQL Login Issue
please expain me the above code