I am using entity framework 5 for saving data from application to SQL Server 2014 with a webservice.It is a winforms Application.
entity class is having date declared as below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities.Commen;
namespace Entities.Masters
{
public class ChittyRecieptEntity:Utility
{
public DateTime ChittyRepaymentDate { get; set; }
}
}
and web services class is created like below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entities.Masters;
using System.Data.Entity;
using Data;
namespace Operations.Masters
{
public class ChittyRecieptOperations
{
public ChittyRecieptEntity DoSaveChittyReciept(ChittyRecieptEntity entity)
{
try
{
using (JMFLEntities ctxt = new JMFLEntities())
{
TblChittyReciept tblobj = new TblChittyReciept();
tblobj.ChittyRepaymentDate = entity.ChittyRepaymentDate;
ctxt.SaveChanges();
}
}
catch (Exception ex)
{
}
return entity;
}
database field is ChittyRepaymentDate ,declared as date and not null
server is in US (godaddy)
this date field is passing from application (using datetime.now) ,but after saving in date field on sql server it is saved as previous date value.
can you tell me what might i have done wrong.
Thanks in advance
George
What I have tried:
while using service from local machine and database on live server, date is saving correctly.
a previous date selected in date picker of application saves correctly
selecting date on datepicker twice (other than current date then current date)
saves correctly
date passing from application with datetime.now and default date of date picker(current date) saves incorrect or previous date
while using break point in debugger can see value of date passing from application is correct and saving is incorrect on live server.