Some background:
I'm running two different installations of SQL Server on two different VMs. I'm attempting to connect to them from my code (which was written for SQL Server 2008 R2). My current .NET framework version is 4.0. My Microsoft SQL Server 2008 R2 installation is running the AdventureWorks designed for it, and my SQL Server 2012 Express installation is running the newer AdventureWorks2012 database. I'm querying Person.Address.
Currently I'm running into an exception saying "DataType cannot be null". I've deduced from looking at the returned schemas that the problem comes from SQL Server 2012 returning a
Microsoft.SqlServer.Types.SqlGeography
datatype. It seems that Type.GetType cannot convert this to something usable and throws an exception. I'm relieved that it's nothing that I've done, but I'm also puzzled because this code should work universally. Keep in mind this code runs flawlessly on SQL Server 2008 R2 (because it lacks the spatial datatype).
I could think of 100 bad ways to handle this. However I wanted to come to you guys for suggestions on what to do. Will upgrading .NET to 4.5 remedy the situation? Do I have to change my code at all to accommodate the new datatype? Should I worry about the spatial datatypes if my application doesn't deal with them? How do I handle this, because obviously SqlClient and Type.GetType don't do a good job at it.
Thank you!