Print Page | Close Window

Sql Server 2008 Geography Data Type

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3457
Printed Date: 21-Jan-2026 at 7:09pm


Topic: Sql Server 2008 Geography Data Type
Posted By: mstevenson
Subject: Sql Server 2008 Geography Data Type
Date Posted: 25-May-2012 at 3:55am
Is DevForce classic 3.7.6 compatible with Sql Server 2008 spatial data types? I get the following error when I include geography database column in the Object Mapper.
IdeaBlade.Persistence.PersistenceManagerSaveException was caught
  Message=Save failed - Operand type clash: image is incompatible with geography
  Source=IdeaBlade.Persistence
  StackTrace:
       at IdeaBlade.Persistence.PersistenceManager.DoSaveDataSet(IEnumerable pDataRows, SaveOptions pSaveOptions)
       at Model.IRWPersistenceManager.SaveChanges() in C:\Model\IRWPersistenceManager.vb:line 339
       at UI.SavingService.SaveAll() in C:\UI\BaseClasses\SavingService.vb:line 39
  InnerException: System.Data.OleDb.OleDbException
       ErrorCode=-2147217913
       Message=Operand type clash: image is incompatible with geography
       Source=Microsoft OLE DB Provider for SQL Server
       StackTrace:
            at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
            at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
            at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
            at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
            at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
            at IdeaBlade.Persistence.Server.TransactionManagerHelper.SaveTable(EntityTable pTable, Boolean pDeleting, PostSaveHandler pPostSaveHandler, Boolean pExcludeFromRefetch)
            at IdeaBlade.Persistence.Server.TransactionManagerHelper.Save(DataSet pDataSet, SaveOptions pSaveOptions)
       InnerException:



Replies:
Posted By: sbelini
Date Posted: 25-May-2012 at 10:24am
Himstevenson,
 
I've moved this post to DevForce Classic instead.
 
Silvio.


Posted By: kimj
Date Posted: 25-May-2012 at 6:44pm
DevForce Classic does not directly support spatial data, but you can work around the limitation.
 
Instead of defining the data column as a Geography type you can use varbinary(max), so that DevForce can read and write the column.  Within your code you can then convert the byte array to a SqlGeography type when needed.
 
For example, when saving you can use STAsBinary to obtain the byte array to be saved in the database column.  For example:
    myEntity.MyGeoAsBinaryProp = mygeogVar.STAsBinary().Buffer
 
To create a SqlGeometry object from a queried entity you can use something like this:
  Dim sqlBytes = New SqlBytes(myEntity.MyGeoAsBinaryProp)
  Dim geog = SqlGeography.STGeomFromWKB(sqlBytes, mysrid)
 
 
 



Print Page | Close Window