SQL 2008 and database schema

Topics: Data Access
Jan 29 at 2: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.

Thanks..
Coordinator
Jan 30 at 7:18 PM
You can either provide a qualified table name ("schema.table") or set the TableSchema property prior to using the provider.
Feb 2 at 1: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.. :-)
Coordinator
Feb 2 at 9:57 PM
Could you post the fully qualified table name?
Feb 4 at 3:25 PM
it is sde.gisadmin.di (Select * from sde.gisadmin.di).
Coordinator
Feb 5 at 9: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 at 11:51 AM
Thank you, it works perfectly :-)