public List<employee> AddEmployee()
{
List<employee> employee = new List<employee>();
Employee objemp = new Employee();
try
{
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("sp_insert_employee_tblEmployee", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Name", objemp.Name);
cmd.Parameters.AddWithValue("@Gender", objemp.Gender);
cmd.Parameters.AddWithValue("@City", objemp.City);
cmd.Parameters.AddWithValue("@DateofJoining", objemp.Dateofjoining.ToShortTimeString());
con.Open();
cmd.ExecuteNonQuery();
}
employee.Add(objemp);
}
catch(Exception ex)
{
throw;
}
return employee;
}
}
What is wrong with this method please can anybody help me
getting following exception.
Procedure or function 'sp_insert_employee_tblEmployee' expects parameter '@Name', which was not supplied.
Procedure is --
Create procedure [dbo].[sp_insert_employee_tblEmployee]
@Name varchar(50) NULL,
@Gender varchar(50) NULL,
@City Varchar (50) NULL,
@Dateofjoining datetime
as
begin
Insert into tblEmployee values(@Name,@Gender,@City,@Dateofjoining)
End