[fdo-internals] SQL Server, connection and schema
Brent Robinson
brent.robinson at autodesk.com
Tue Nov 22 16:10:23 EST 2011
Hi,
The ApplySchema command for this provider throws a chain of exceptions, one for each error that occurred. The 1st one has the general "Schema dbo has errors;cannot apply it" message, but subsequent ones provide more details. Does your code catch the Exception that is thrown by Execute()? If it does then following down the InnerException members should give you more info as to why the ApplySchema failed.
Brent.
-----Original Message-----
From: fdo-internals-bounces at lists.osgeo.org [mailto:fdo-internals-bounces at lists.osgeo.org] On Behalf Of mdelsinne
Sent: Tuesday, November 22, 2011 12:10 PM
To: fdo-internals at lists.osgeo.org
Subject: [fdo-internals] SQL Server, connection and schema
*Hello,
I try to create spatial data in SQL Server 2008, I use the provider:
OSGeo.SQLServerSpatial.3.6*
*I manage to connect to my database, it works:*
connProperties.SetProperty ("Service", "host"); connProperties.SetProperty ("Username", "user"); connProperties.SetProperty ("Password", "****"); connProperties.SetProperty ("DataStore", "bdd"); connState = conn.Open ();
*I created my feature class + properties:*
FeatureClass aFeatureClass FeatureClass = new ("CLASSTEST", "");
// Add a id property
DataPropertyDefinition idProp = new DataPropertyDefinition("ID", "");
idProp.DataType = DataType.DataType_Int64;
idProp.IsAutoGenerated = true;
idProp.Nullable = false;
aFeatureClass.Properties.Add(idProp);
aFeatureClass.IdentityProperties.Add(idProp);
idProp.Dispose();
// Add a key property
DataPropertyDefinition keyProp = new DataPropertyDefinition("KEY", "");
keyProp.DataType = DataType.DataType_String;
keyProp.Length = 255;
aFeatureClass.Properties.Add(keyProp);
keyProp.Dispose();
// Add a name property
DataPropertyDefinition nameProp = new DataPropertyDefinition("NAME", "");
nameProp.DataType = DataType.DataType_String;
nameProp.Length = 255;
aFeatureClass.Properties.Add(nameProp);
nameProp.Dispose();
// Add a url property
DataPropertyDefinition urlProp = new DataPropertyDefinition("URL", "");
urlProp.DataType = DataType.DataType_String;
urlProp.Length = 255;
aFeatureClass.Properties.Add(urlProp);
urlProp.Dispose();
// Add a geometry property
GeometricPropertyDefinition geomProp = new GeometricPropertyDefinition("Geom", "");
geomProp.GeometryTypes =
(int)GeometryType.GeometryType_MultiGeometry;
aFeatureClass.Properties.Add(geomProp);
aFeatureClass.GeometryProperty = geomProp;
geomProp.Dispose();
*An existing schema (dbo), confirmed by DescribeSchemaMapping.*
FeatureSchema aFeatureSchema = new FeatureSchema("dbo", ""); aFeatureSchema.Classes.Add(aFeatureClass);
IApplySchema applySchema = (IApplySchema) connect.CreateCommand (OSGeo.FDO.Commands.CommandType.CommandType_ApplySchema);
applySchema.FeatureSchema FeatureSchema = aFeatureSchema; applySchema.Execute ();
*Everything seems set up correctly, yet it not work:* Schema dbo has errors;cannot apply it
*But impossible to apply the schema:*
Thank's !!!
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/SQL-Server-connection-and-schema-tp7021142p7021142.html
Sent from the FDO Internals mailing list archive at Nabble.com.
_______________________________________________
fdo-internals mailing list
fdo-internals at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/fdo-internals
More information about the fdo-internals
mailing list