This project has moved and is read-only. For the latest updates, please go here.

Data Providers for MsSqlSpatial and SqlServer 2008 added to june 21st drop

Topics: Data Access, SharpMap v2.0
Jun 23, 2008 at 1:46 PM
Edited Jun 23, 2008 at 5:52 PM
Hi everyone,
I have uploaded a preliminary set of database providers for SharpMap v2.
Providers for:
Sql Server 2008 (tested with Feb CTP)
SqlServer 2005/MsSqlSpatial
There is also a set of base classes which are hopefully abstract enough to be useful as a basis for oracle / postgres etc.

EDIT: this is now part of the June 21st Drop

Jun 26, 2008 at 10:50 AM
Edited Jun 26, 2008 at 10:54 AM

I've tried to built an OleDb-Provider on the base of your abstract Db-Provider. The problem with OleDb seems to be that the OleDbDataReader doesn't like being called from a different thread than the one it created it, at least I get a FailedQI exception on IRowset which lead me to this:

Bug: Error message when you call an OleDbDataReader object: System.InvalidCastException: QueryInterface for interface IRowset failed

Any ideas?

Jun 26, 2008 at 11:36 AM
Hi FObermaier, Just to let you know the latest code is here :
In response to your issue I have made SpatialDbProviderBase.ExecuteFeatureDataReader virtual so perhaps you can override it set the threading model to Apartment as per the Ms KB and then call the base method. Let me know how you get on.. cheers jd
Jun 26, 2008 at 1:12 PM
Edited Jun 26, 2008 at 3:41 PM
Hello JohnDiss,
I've followed your suggestion but didn't have any luck. The FailedQI-Exception is thrown in the SpatialDataReader.GetValue function, which is invoked by a STAThread from FeatureMerger.setFeatureRowFromIFeatureDataRecord so I think I have to get the Sharpmap.MapPresenter into an MTA state, too.
Thanks anyway


Jun 26, 2008 at 4:29 PM
I don't think an MTA will work - WinForms requries an STA. How is the OleDb call getting invoked cross-thread?
Jun 26, 2008 at 5:09 PM
Edited Jun 26, 2008 at 5:15 PM

codekaizen wrote:
I don't think an MTA will work - WinForms requries an STA. How is the OleDb call getting invoked cross-thread?

The AsyncFeatureProviderAdapter.BeginExecuteQuery starts the new thread via ThreadPool.QueueUserWorkItem
Starting RenderAllLayers with a ThreadPool.QueryUserWorkItem call -and some additions- does work for a while but eventually the Indexes are messed up.
  ThreadPool.QueueUserWorkItem(queueableBeginQuery, asyncResult);
with just
in the AsyncFeatureProvider.BeginExecuteQuery() seems to works fine (for me).

Jul 30, 2009 at 5:47 PM

I get a 'Repository Access Denied' XML message when I try to access any repository under

Did something change?

Jul 30, 2009 at 5:59 PM

Hi Brian, that svn is deprecated - the contents are merged into the main v2 svn @ hth jd

Jul 30, 2009 at 7:04 PM

Thanks for answering so quickly!  You rock! :)