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

Topics: Data Access, SharpMap v2.0
Coordinator
Jun 23, 2008 at 12:46 PM
Edited Jun 23, 2008 at 4: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

Coordinator
Jun 26, 2008 at 9:50 AM
Edited Jun 26, 2008 at 9:54 AM
Hello,

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
http://support.microsoft.com/?scid=kb%3Ben-us%3B313510&x=11&y=12

Any ideas?
FObermaier

Coordinator
Jun 26, 2008 at 10:36 AM
Hi FObermaier, Just to let you know the latest code is here : http://sharpmapv2aspnet.googlecode.com/svn/trunk/SharpMap.Data.Providers.Db/
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
Coordinator
Jun 26, 2008 at 12:12 PM
Edited Jun 26, 2008 at 2: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

FObermaier

Coordinator
Jun 26, 2008 at 3:29 PM
I don't think an MTA will work - WinForms requries an STA. How is the OleDb call getting invoked cross-thread?
Coordinator
Jun 26, 2008 at 4:09 PM
Edited Jun 26, 2008 at 4: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.
Replacing
  ThreadPool.QueueUserWorkItem(queueableBeginQuery, asyncResult);
with just
  queueableBeginQuery(asyncResult)
in the AsyncFeatureProvider.BeginExecuteQuery() seems to works fine (for me).


FObermaier
Jul 30, 2009 at 4:47 PM

I get a 'Repository Access Denied' XML message when I try to access any repository under http://sharpmapv2aspnet.googlecode.com/svn/trunk/SharpMap.Data.Providers.Db/

Did something change?

Coordinator
Jul 30, 2009 at 4:59 PM

Hi Brian, that svn is deprecated - the contents are merged into the main v2 svn @ http://sharpmapv2.googlecode.com hth jd

Jul 30, 2009 at 6:04 PM

Thanks for answering so quickly!  You rock! :)