Question

I am trying to write a code in c-sharp to import shapefile to spatialite database.

Code written to initialize sqlite connection as follows,

SQLiteConnection conn = new SQLiteConnection(@"Data Source=" + sqLiteFile + ";Version=3;");
conn.Open();

SQLiteCommand cmd = new SQLiteCommand(@"SELECT load_extension('libspatialite-2.dll')", conn);
cmd.ExecuteNonQuery();

cmd = new SQLiteCommand("select .loadshp ShapeTest ShapeTest CP1252 23032", conn);
cmd.ExecuteNonQuery(); //Getting error here.

I think there is a syntax error. Any one with any idea?

Was it helpful?

Solution

.loadshp is provided by the command line utilities, not by the spatialite extension. I think what you wanted to do is to use the VirtualShape virtual table:

"CREATE VIRTUAL TABLE ShapeTest USING VirtualShape(\"ShapeTest\", \"CP1252\", 23032)"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top