Friday, March 31, 2006

Error converting data type varchar to datetime

Of the errors you can get in software, the two most basic errors are a syntax error, and a data type error. Neither of these have anything to do with actual program logic, but are caused by not doing the most basic of things that can be done when you program. This is the type of incorrect coding that should never be done, and certainly is only a work product of the most junior of programmers. The data type error is again one of the most basic things that can be tested by the testing team, so it should never make it to production software.

Good software engineering is an iterative process that involves cycling through requirements, coding, testing, and deployment. These most basic of errors are indicative of software teams that do not follow best practices.

While attempting to access http://aff.dbpn.com/aff_home.aspx, for use with Doyle's Room, I got an error. A data type error, "Error converting data type varchar to datetime."

It sems if you press the "update" button without first selecting dates, you get this untrapped error.

Error converting data type varchar to datetime.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Error converting data type varchar to datetime.

Source Error:


An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can be
identified using the exception stack trace below.

Stack Trace:

[SqlException: Error converting data type varchar to datetime.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +740
System.Data.SqlClient.SqlCommand.ExecuteReader() +41
AffMan.aff_home.DoReport() in c:\inetpub\wwwroot\AffMan\aff_home.aspx.cs:59
AffMan.aff_home.btnUpdate_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\AffMan\aff_home.aspx.cs:105
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI

.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent

(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

No comments: