Hi,
i facing the issue with my updating service on reg-start date. when i try to upload the date from date picker in client side, it will not updated in back end. The error shows like "Year, Month, and Day parameters describe an un-representable DateTime ".
Here is my Code :
if (lblRegStart.Text != txtNewRegStart.Text)
{
string[] sDate = txtNewRegStart.Text.Split('/');
DateTime regStartDt = new DateTime(Convert.ToInt16(sDate[2]),
Convert.ToInt16(sDate[1]), Convert.ToInt16(sDate[0]), 23, 59, 59);
if (regStartDt.CompareTo(DateTime.Now) < 0)
{
lblMessage.Text = "The Reg Start date should not be earlier than today";
return false;
}
string[] sInsDtTo = hidInsDtTo.Value.Split('/');
if (regStartDt.CompareTo(new
DateTime(Convert.ToInt32(sInsDtTo[2].Substring(0, 4)),
Convert.ToInt32(sInsDtTo[0]), Convert.ToInt32(sInsDtTo[1]), 23, 59, 59))
> 0)
{
lblMessage.Text = "The Reg Start date should not be later than the date of the Policy Expiry";
return false;
}
//string sDrFormat = "yyyy-MM-dd";
//Response.Write(regStartDt.ToString(sDrFormat));
sResp = adnicService.update_regstart(lblrefno.Text, regStartDt.ToString("mm/dd/yyyy"), ref iErr);
//sResp = adnicService.update_regstart(lblrefno.Text, regStartDt.ToString(sDrFormat), ref iErr);
//sResp = adnicService.update_regstart(lblrefno.Text, txtNewRegStart.Text, ref iErr);
if (iErr != 0)
{
lblMessage.Text = sResp;
return false;
}
}
Any help will be greatly appreciated. i'm in critical situation.
Thanks in advance.
AL MUBARAKPosted Jun 19, 2012, 1:40 AM
The error is coming with this line given below, whenever the datet receives from client (mdy) format, it updates the date in database. So i did the format of date with regStartDt.ToString("mm/dd/yyyy") in the webservice.
sResp = adnicService.update_regstart(lblrefno.Text, regStartDt.ToString("mm/dd/yyyy"), ref iErr);
Now the thing is, I already check the Region and Language with Time settings in control panel, i change the same way i got it. but still the error is persists.
Hope you can understand. need more calrify, please let me know.
Jignesh TrivediPosted Jun 18, 2012, 11:41 PM
Is there error come from SQL?
Can please share line info where you got error also full error?
thx.