Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
As per this code i m getting "Invalid object name 'timesheetdate'."

C#
foreach (ManageTimeSheetsModel obj in newlist)
{
    SqlCommand cmd = new SqlCommand("Timesheet_sp", con);
 
    cmd.Parameters.Add("@EmployeeID",SqlDbType.Int).Value=obj.EmployeeID;
    cmd.Parameters.Add("@OrganisationID", SqlDbType.Int).Value = obj.OrganisationID;
    cmd.Parameters.Add("@Timesheetdate", SqlDbType.DateTime).Value = obj.Timesheetdate;
    cmd.Parameters.Add("@Workinghours", SqlDbType.Decimal).Value = obj.Workinghours;
    cmd.Parameters.Add("@Leavehours", SqlDbType.Decimal).Value = obj.Leavehours;
    cmd.Parameters.Add("@Status", SqlDbType.NVarChar).Value = obj.status;
    cmd.CommandType = CommandType.StoredProcedure;
    //cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = timesheet.Email;
    SqlParameter result = new SqlParameter("@result", SqlDbType.Int);
    result.Direction = ParameterDirection.Output;
    cmd.Parameters.Add(result);
    SqlParameter ErrorMessage = new SqlParameter("@ErrorMsg", SqlDbType.VarChar, 500);
    ErrorMessage.Direction = ParameterDirection.Output;
    cmd.Parameters.Add(ErrorMessage);

    cmd.ExecuteNonQuery();

   //int id = Convert.ToInt32(result.Value.ToString());
    
}

in the model i have intialised :
C#
public int EmployeeID { get; set; }
public int OrganisationID { get; set; }
public decimal Workinghours { get; set; }
public decimal Leavehours { get; set; }
public string status { get; set; }
public DateTime Timesheetdate { get; set; }
public string Email { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
Posted
Updated 26-Feb-13 0:14am
v3
Comments
Richard MacCutchan 26-Feb-13 4:21am    
Please show the code of your stored procedure Timesheet_sp.

1 solution

Check your ManageTimeSheetsModel if it has Timesheetdate
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900