Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone! (again)
On the endless road of learning programming, I ran into another problem:
I've been developing an application with Visual Studio 2010 and Sql Server 2008. Everything worked fine until I've changed from SQL Server 2008(In my Home) to SQL Server 2005 (In the Office). The problem seems to be, as I found on Google, that Sql Server 2005 doesn't support DateTime2.
Is there any way to cast or convert from DateTime2 to the single DateTime?

I'm using ADO.NET Entities Framework to insert and update records on the DB.

Thanks in advance.
Best Regards.


EDIT: A Possible Solution:
Well I've regenerated the model from the SQL Server 2005 Data Base and now works, although of being an effective solution, isn't efficient, because I'm depending on SQL Server 2005 rather than 2008 that is what I use regulary to develop my applications.
If there is a better way to solve the problem would good.
Anyway thanks to aspdotnetdev for the answer.
Posted
Updated 15-Dec-10 16:21pm
v3

1 solution

You could always have both databases make use of datetime and discontinue use of datetime2 altogether.
 
Share this answer
 
Comments
Pablinff 14-Dec-10 13:47pm    
Hi! i've thinking on this solution but i don't know how to change that on the project. I'm using .NET 4 and it seems to be that the DateTime type is by default a DateTime2 type.

Thanks!
AspDotNetDev 14-Dec-10 13:52pm    
Not really sure what is defaulting to DateTime2. Perhaps change the field type in the database to datetime, then regenerate the ADO.Net stuff from the database.
Pablinff 14-Dec-10 14:22pm    
Oh! I understand now, I'll try it and i see if works.
Thanks!
Pablinff 16-Dec-10 9:46am    
Well I've regenerated the model from the SQL Server 2005 Data Base and now works, although of being an effective solution, isn't efficient, because I'm depending on SQL Server 2005 rather than 2008 that is what I use regulary to develop my applications.
If there is a better way to solve the problem would good.
Anyway thanks to aspdotnetdev for the answer.
AspDotNetDev 16-Dec-10 9:54am    
I would need to see some code before I could help you more. It's possible to convert between DateTime and DateTime2. I would just need to see at which point you are trying to do the conversion. And I don't see how using a DateTime means you are "depending on SQL Server 2005". That is a common format available in SQL 2005 and 2008.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900