I am facing the below error
‘int’ does not contain a definition for ‘LeaveType’ and no extension method ‘LeaveType’ accepting a first argument of type ‘int’ could be found (are you missing a using directive or an assembly reference?)
here is my code :
public DataSet GetLeaveRecord(int empID)
{
DataSet ds = new DataSet();
try
{
SqlCommand cmd = new SqlCommand("[p_GetLeaveRecord_LMS]", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
cmd.Parameters.AddWithValue("@LeaveType", empID.LeaveType);
cmd.Parameters.AddWithValue("@IdEmployee", empID.EmployeeId);
cmd.Parameters.AddWithValue("@DateFrom", empIDd.DateFrom);
cmd.Parameters.AddWithValue("@DateTo ", empID.DateTo);
cmd.Parameters.AddWithValue("@Reason", empID.Reason);
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
adapter.Fill(ds);
}
catch (Exception e)
{
throw e;
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
return ds;
}
You are passing
empIDas aninttype parameter and later you are using it as a type in your parameters. For example.I believe you have to pass your object probably of
EmployeeLeavetype in your methodOr you may get your object based on the
IDin your method and then use that in your parameters