ThinkGeo.com    |     Documentation    |     Premium Support

Throw exception when load Form

Hi Team,

"Unable to open database file"

at System.Data.SQLite.SQLite3.Open(String strFilename, String vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool)
at System.Data.SQLite.SQLiteConnection.Open()
at ThinkGeo.MapSuite.Layers.SqliteFeatureSource.GetColumnNames(String connectionString, String tableName)
at ThinkGeo.MapSuite.Layers.SqliteValidatorHelper.CheckFeatureIdAndGeometryColumn(String connectionString, String tableName, String featureIdColumn, String geometryColumnName)
at ThinkGeo.MapSuite.Layers.SqliteFeatureSource.OpenCore()
at ThinkGeo.MapSuite.Layers.FeatureSource.Open()
at ThinkGeo.MapSuite.Layers.FeatureLayer.OpenCore()
at ThinkGeo.MapSuite.Layers.Layer.Open()
at ThinkGeo.MapSuite.Layers.WorldStreetsLayer.OpenCore() in f:\CAD\PhoenixScrum\Dev\PhoenixCAD\Component\KPI.Global.PnxOfflineMapCtrl\KPI.Global.PnxOfflineMapCtrl\WorldStreetsLayer.cs:line 134
at ThinkGeo.MapSuite.Layers.Layer.Open()
at KPI.Global.PnxOfflineMap.PnxOfflineMapCtrl.LoadWorldBaseLayer() in f:\CAD\PhoenixScrum\Dev\PhoenixCAD\Component\KPI.Global.PnxOfflineMapCtrl\KPI.Global.PnxOfflineMapCtrl\PnxOfflineMapCtrl.cs:line 311
at KPI.Global.PnxOfflineMap.PnxOfflineMapCtrl.PnxOfflineMapCtrl_Load(Object sender, EventArgs e) in f:\CAD\PhoenixScrum\Dev\PhoenixCAD\Component\KPI.Global.PnxOfflineMapCtrl\KPI.Global.PnxOfflineMapCtrl\PnxOfflineMapCtrl.cs:line 123

Regards,
Tamilarasan.

Hi Tamil,

Please double check the database path, and then try to open it by any 3rd part utility.

If it can be opened by other utility but cannot opened by our code, please upload a sample contains your code to open it and attach the database, you can clear the data in it or leave some items for test, so our developer can look into it.

Regards,

Ethan

Hi Ethan,

We tried but not able to find the issue .

I am using mappoint and ThinkGeo map in my application. If have toggle switch of mappoint and ThinkGeo map.

Some time map loaded and some cause it throw “Cant open” for SQL lite DB exception.

regards,
Tamilarasan.

Hi Ethan,

Here attach sample application we using both map point and ThinkGeo map.

Please install map point and using Dallas sq lite file

sq lite path like WorldStreetsLayerSample\bin\Debug\App_Data

map point path like C:\Program Files (x86)\Microsoft MapPoint 2013\Samples\SampleTemplate.ptt

we want to use both map point and thinkgeo map.

Please guide us.sample.zip (2.9 MB)

regards,
Tamilarasan.

Hi Tamilarasan,

Thanks for upload your project, I viewed your switch code, and it looks your code don’t release the layer or close the connection when you switch to MapPoint.

I think you should want to do that because each time you connect the sqlite database using the same connection string. So please try to close the layer when you switch map.

Wish that’s helpful.

Regards,

Ethan

Hi Ethan,

Please make first select map point and open thinkgeo map .

Now i get same exception Unable to open Database.

Please check like that way.

Regards,
Tamilarasan.

Hi Tamilarasan,

It looks I cannot find the MapPoint download link even from MS’s website: https://www.microsoft.com/mappoint/

So do you know where it can be found or whether you can reproduce when the project don’t contains MapPoint?

Regards,

Ethan

Hi Ethan,

Once loaded map point then only we face the issue.

Regards,
Tamilarasan.

Hi Tamilarasan,

Thanks for your update…

We tested your demo using our sqlite database (ConnectionString: “Data Source=C:\Doc\Data\WorldMapKit-3857.sqlite;Version=3;Read Only=True;”), and it works fine. Here attachment is our test video.

Post8971_20180305.zip (2.4 MB)

We reviewed the demo code, found that the sqlite connection string is a relative path. We tested the relative path connection string and reproduce your issue in the case.

So we guess that MapPoint modify the base folder when loading, which causes SQLiteConnection is unable to open the database file.

You can use absolute path as connection string to resolve the issue.

If you have any questions, please feel free to let us know.

Regards,

Ethan

Hi Ethan,

Thanks, It was very useful.

Regards,
Tamilarasan.

Hi Tamilarasan,

I am glad to hear that’s helpful.

Regards,

Ethan