Error 'There was an error in a part of the date format.'
Posted: Wed May 15, 2013 6:51 am
Hello,
I try to add a field to the database AuditTrail with a script, but I get the error below in the script:
"There was an error in a portion of the date format. [Expression (if known) =]"
Here is my code:
Someone will have an idea of MY error?
Thank you
I try to add a field to the database AuditTrail with a script, but I get the error below in the script:
"There was an error in a portion of the date format. [Expression (if known) =]"
Here is my code:
Code: Select all
/// <summary>
/// Tries to add LogOP into the database
/// </summary>
void Button2_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e)
{
if (DB_LogOP.ConnectToDataBase())
{
string DateTime = Globals.Tags.SystemTagDateTime.Value.ToString();
string CurrentOP = Globals.Tags.SystemTagCurrentUser.Value.ToString()
// Using try/catch to prevent a crash, should anything go wrong.
try
{
SqlCommand = new SqlCeCommand("INSERT INTO AuditLog (Message, Description, TimeStamp, UserName) VALUES ('Message', 'Description', '"+DateTime+"', '"+CurrentOP+"')", DB_LogOP.SqlConnection);
SqlCommand.ExecuteNonQuery();
}
catch (SqlCeException ex)
{
MessageBox.Show(string.Format("{0}",ex.Message),"Erreur d'accès");
}
finally
{
// Dispose the SqlCommand object.
SqlCommand.Dispose();
SqlCommand = null;
// Disconnects from the database.
DB_LogOP.DisconnectFromDataBase();
}
}
}
Thank you