problem with a shapefile (another one)

Topics: User Forum
Dec 14, 2006 at 3:21 PM
hello,

I'm trying to use this procedure : ST.ImportFromShapefile.
@shapefile = N'D:\developpement\Visual Studio 2005\Projects\mssqlspatial\data test\route_polyline.shp',
@schema_name = N'dbo',
@tablename = N'routepolyline',
@columnname = N'thegeom',
@srid = 27572,
@type = N'POLYLINE'
(route_polyline is a very tiny file, only two polylines in it)

After I solved this problem (that another user previously had and that is copied below just for information)

Msg 6522, Level 16, State 1, Procedure ImportFromShapefile, Line 0
A .NET Framework error occurred during execution of user defined routine or aggregate 'ImportFromShapefile':
System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
System.Security.SecurityException:
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at SharpMap.Data.Providers.ShapeFile.ParseHeader()
at SharpMap.Data.Providers.ShapeFile..ctor(String filename, Boolean fileBasedIndex)
at SharpMap.Data.Providers.ShapeFile..ctor(String filename)
at StoredProcedures.ImportFromShapefileMain(String shapefile, String schemaname, String tablename, String column_name, Int32 srid, String type, String connectionString, Int32& importedRows, TimeSpan& elapsedTime)
at StoredProcedures.ImportFromShapefile(SqlString shapefile, SqlString schemaname, SqlString tablename, SqlString column_name, SqlInt32 srid, SqlString type)

here is a new one, with the same shape file

Msg 6522, Level 16, State 1, Procedure ImportFromShapefile, Line 0
A .NET Framework error occurred during execution of user-defined routine or aggregate "ImportFromShapefile":
System.Data.SqlClient.SqlException: The ALTER TABLE statement conflicted with the CHECK constraint "enforcetyperoutepolylinethegeom". The conflict occurred in database "bsevierge", table "dbo.routepolyline", column 'the_geom'.
System.Data.SqlClient.SqlException:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnectionSmi.EventSink.ProcessMessagesAndThrow(Boolean ignoreNonFatalMessages)
at Microsoft.SqlServer.Server.SmiEventSink_Default.ProcessMessagesAndThrow(Boolean ignoreNonFatalMessages)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQuerySmi(Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at MsSqlSpatial.GeometryTable.ExecuteAddConstraintGeometryType(SqlCommand command, String schemaName, String tableName, String columnName, String type)
at StoredProcedures.ImportFromDatasource(IProvider datasource, String schemaName, String tableName, String columnName, Int32 srid, String type, String connectionString, ImportFromDatasourceProcess process, Int32& importedRows, TimeSpan& elapsedTime)
at StoredProcedures.ImportFromShapefileMain(String shapefile, String schemaname, String tablename, String column_name, Int32 srid, String type, String connectionString, Int32& importedRows, TimeSpan& elapsedTime)
at StoredProcedures.ImportFromShapefile(SqlString shapefile, SqlString schemaname, SqlString tablename, SqlString column_name, SqlInt32 srid, SqlString type)
.

(1 row(s) affected)


If anyone knows what's going on, please let me know

thanks

David
Dec 14, 2006 at 5:17 PM
Your shapefile might contain MultiLinestrings. I'm not sure whether 'POLYLINE' can map both Linestrings and MultiLinestrings.
And is it called polyline? According to the features, MsSqlSpatial uses the terms Linestring and MultiLinestring.
Dec 15, 2006 at 3:12 PM
Quite right !
It is LINESTRING indeed, and not POLYLINE
Thanks for pointing it out !
Back on track now....