I look after a website which has news/blog section. As usual, admin can create/edit articles. It's been running fine for years but suddenly last week, I became to get an error saying "Input string was not in a correct format." when creating/editing articles. And I also get error notification email from the system as below;
Message: Error converting data type varchar to datetime.
The entry page has date fields but I use the same format I've been using and nothing has changed since the last time I created/edited articles successfully. The same files and code in the server. It suddenly started not to let me create/edit anything. Even it won't let me save articles without changing anything of the article.
It's running on ASP.Net(C#), MS SQL Server and IIS. As nothing has changed, I have no idea where to start but can this be happened?? And what would be the cause?
I don't know what exactly the culture setting was in the Windows Server but I don't see any incorrect setting. Current correct Region, Date and Time are there. No one has accessed to the server between the dates something went wrong. The SQL server uses the different setting from the server ones but it has been like this.
The website has some sections and the news/blog section gets the error but the other section, which also uses dates, don't get an error. Obviously these different sections uses the different files. So I think the server/SQL settings are OK. But as I mentioned, the files haven't changed at all.
Any other possibilities?? Thanks for your help.
Try to check if anyone has changed the culture settings on the server (on which your MS SQL Server is running). Control Panel, Region and Language.
DateTime parsing can depend on those settings if it uses the current culture on the machine.
Assumption 1: Your asp.net application may unnecessary convert DateTime.ToString() when constructing the sql insert/update command.
Assumption 2: It gets the string as it is and uses the session login default language and format (see SET LANGUAGE / SET FORMAT in SQL). Check if the default language/format has changed in your sql.