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

SQL 2008 and database schema

Topics: Data Access
Jan 29, 2016 at 3:49 PM
Hi !

How can I load data using SqlServer2008 when the database schema is not dbo ?? It retuns me "A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll". If I copy the table in dbo schema it works fine.

Jan 30, 2016 at 8:18 PM
You can either provide a qualified table name ("schema.table") or set the TableSchema property prior to using the provider.
Feb 2, 2016 at 2:54 PM
Here's what I'm doing...

im layInfo As SharpMap.Layers.VectorLayer = New SharpMap.Layers.VectorLayer("LN")
Dim ConnStr As String = "Server=sopfeu-esri-sql\esri_sde;Database=SDE;Integrated Security=SSPI" ' User Id=myUser;Password=MyPass"
Dim d As SharpMap.Data.Providers.SqlServer2008 = New SharpMap.Data.Providers.SqlServer2008(ConnStr, "DI", "SHAPE", "OBJECTID", SharpMap.Data.Providers.SqlServerSpatialObjectType.Geometry)
d.TableSchema = "sde.gisadmin"
layInfo.DataSource = d
layInfo.SRID = 32198

It is still returning an error. What am I doing wrong ??

Thank you.. :-)
Feb 2, 2016 at 10:57 PM
Could you post the fully qualified table name?
Feb 4, 2016 at 4:25 PM
it is sde.gisadmin.di (Select * from sde.gisadmin.di).
Feb 5, 2016 at 10:02 AM
I just noticed that while you can set the TableSchema, it is not used. So, as a workaround, you need to set Table to the fully qualified table name (sde.gisadmin.di):
d.Table = "[sde.gisadmin].[di]";
d.TableSchema = string.Empty;
This will get fixed in the next release.
Feb 9, 2016 at 12:51 PM
Thank you, it works perfectly :-)