This project is read-only.

Import Shape file Using SP ST.ImportFromShapefile

Mar 31, 2009 at 10:11 AM
Hi,
      I tried to import a shape file using below command -

      EXECUTE ST.ImportFromShapefile 'D:\Amresh_1Dec07\eraytec Projects\Taiwan Taxi Software\Doc\17-03-09\PND Navigation Map\Taiwanmap with POI\Taiwanmap with POI\TAIWAN_TUNNEL.SHP', 'db', 'TaipeiTaxi', 'wkb_geometry1', 32766, 'GEOMETRY';

     but when i execute above SP i received following error -
  
     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 StoredProcedures.ImportFromShapefileMain(String shapefile, String schema_name, String table_name, String column_name, Int32 srid, String type, String connectionString, Int32& importedRows, TimeSpan& elapsedTime)
   at StoredProcedures.ImportFromShapefile(SqlString shapefile, SqlString schema_name, SqlString table_name, SqlString column_name, SqlInt32 srid, SqlString type)
.

waiting for reply, plz reply soon
Thanx in Advance

Regards,

Amresh

    

        I
Mar 31, 2009 at 10:21 AM
I am assuming your assembly has less than external_access permission set either use the console app to import the shapefile or increase the permission
ALTER ASSEMBLY MsSqlSpatialLibrary WITH PERMISSION_SET = UNSAFE
(at your own risk)
Apr 1, 2009 at 5:25 AM
Hi ,

thanx for your reply, but i didn't get your answer.

I also used console app to import but i received following error -


Unhandled Exception: System.ArgumentOutOfRangeException: Length cannot be less
than zero.
Parameter name: length

at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length,
Boolean fAlwaysCopy)

at SharpMap.Data.Providers.ShapeFile..ctor(String filename, Boolean fileBased
Index)

at StoredProcedures.ImportFromShapefileMain(String shapefile, String schema_n
ame, String table_name, String column_name, Int32 srid, String type, String conn
ectionString, Int32& importedRows, TimeSpan& elapsedTime)

at MsSqlSpatialConsole.Program.ImportShp(ArgParser arg, String schema, String
table, String column, Int32 srid, String type, String connectionString)
at MsSqlSpatialConsole.Program.Main(String[] args)


waiting for reply, plz reply soon

Thanx in advance.

Regards,

Amresh

From: [email removed]
To: [email removed]
Date: Tue, 31 Mar 2009 02:21:55 -0700
Subject: Re: Import Shape file Using SP ST.ImportFromShapefile [MsSqlSpatial:51800]

From: johndiss
I am assuming your assembly has less than external_access permission set either use the console app to import the shapefile or increase the permission
ALTER ASSEMBLY MsSqlSpatialLibrary WITH PERMISSION_SET = UNSAFE
(at your own risk)


So many new options, so little time. Windows Live Messenger.
Apr 1, 2009 at 10:12 AM
Hi Amresh, I think the first issue is due to the permission set which the assembly is running under being to low. My guess is that you need to increase the permission set by executing the following sql against the db
ALTER ASSEMBLY MsSqlSpatialLibrary WITH PERMISSION_SET = UNSAFE
which you do at your own risk.
The second issue you had looks like it may come from a corrupt shapefile
hth jd