I set my system region settings to "spanish", So I'm getting the time format like: 20/02/2016 02:39:40 a.m.
;I have stored this value in datetime variable and passed to sql database table. I set my database default language also to "spanish", at the time of inserting datetime varaible..getting exception
conversion failed when converting date and/or time from character string
due to having "." (preiod) in a.m./p.m. I am getting this exception. I searched a lot on this issue, every where converting the datetime varaible to string format.But I should pass this as a datetime variable only.
So please let me know how to get current system datetime without am/pm or without having "." in am/pm
//Here is my code:
DomainSchema.DOMAINRow drDomain = domain_dataset.DOMAIN.NewDOMAINRow();
//Assigning the values to the DataRow of the table Domain
drDomain.CREATED_DATE = DateTime.Now;
drDomain.LAST_UPDT_DATE = DateTime.Now;
domain_dataset.DOMAIN.AddDOMAINRow(drDomain);
CultureInfo i;
i = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
if (i.Name == "es-PE")
{
CultureInfo c = CultureInfo.CreateSpecificCulture("es-ES");
String s = DateTime.Now.ToString(c); //getting s="20/02/2016 08:07:54"
DateTime d = DateTime.Parse(s, c, System.Globalization.DateTimeStyles.AssumeLocal); //geting d="20/02/2016 08:07:54 a.m."
}
//method that uses this dataset
public override string Create(DataSet ds, string tableName, IDbTransaction transaction, IPrincipal user)
{
DataRow dRow = null;
CommandStatement cmdStatemnt;
string strResult = string.Empty;
try
{
dRow = ds.Tables[tableName].Rows[0];
cmdStatemnt = Execute(dRow, tableName, transaction, true, null, user);
//Here I'm getting exception,conversion failed when converting date and/or time from character string,due to having "." in "a.m."
}
}
thanks in advance.