Question : SQL 2008 time(7) data type and Classic ASP code

I am experiencing a very strange problem with time(7) datype and my ASP code. The DB is running SQL 2008 Developer edition. I get all the results if I Select rows from the Management Studio and if I execute the SP on the server directly through the Mgmt Studio, but I can't get it to work on my ASP page.

When I set the column data type time(7) or time() anything for that matter, I either get Type Mismatch error when simply writing to the page (Response.Write rs("Col1")) without any type of formatting or get no results in my recordset at all.

I am selecting three columns from a table. The first one is nvarchar and two others are time(7). If I do nothing to the columns in my select statements
Ex:
SELECT ColA,ColB,ColC FROM TableA ORDER BY id
I get no results at all.

If I change the column data types to datetime (or datetime2) and then CAST it as time(7) I get a Type Mismatch error.

Ex.
SELECT Col1,CAST(Col2 AS time(7)) AS Col1Time, CAST(Col3 AS time(7)) AS Col3Time FROM Table A ORDER BY id

Is there a known issue with ASP not being able to handle/recognize this new data type?

Thanks!

Answer : SQL 2008 time(7) data type and Classic ASP code

I FOUND A SOLUTION!!!! And it only took me 18 hours...

Thanks for the help mwvisa1 and although your suggestions did not provide a direct solution, you did put time into this so I'll definitely award you some points.

The solution was in the connection string. Apparently, on certain servers running SQL 2008 this driver:
Driver={SQL Server Native Client 10.0} is treating the time data type differently than
Driver={SQL Server}

Although I don't have an explanation of why this was happening (I am not a database guru) I do know that changing the default driver helps resolve this issue.

So bottom line that the Native Client 10.0 interprets certain data types differently. And changing the time precision to time(0) from the default time(7) or whatever you may have it set it to, will help better fit older applications/code. Hopefully there aren't many dinosaurs like me using Classic ASP.
Random Solutions  
 
programming4us programming4us