Problem:
My app was trying to read a local copy of SQLite db. I kept getting this error. It was crazy since the file is present in the project. Each time I would try to open the file with the connection string I would get this error
Solution:
It was simple enough. I have forgot to set my Build Action properties on the SQLite db file. It set to none when it should be set to Content.
Build Action = Content.
This missive records my trials and tribulations as I code my way through projects. Fix the problem once and reuse the solution!
Showing posts with label SQLite. Show all posts
Showing posts with label SQLite. Show all posts
Thursday, December 3, 2015
Tuesday, September 29, 2015
Access Existing SQLite database in Crossplatform solutions
Background:
I am trying to build out a crossplatform mobile solution using MVVMCross. Stuart Lodge's N+1 series does a great job explaining how to use a new sqlite database. The missing use case is how to implement the solution for an existing sqlite database. I am working on that solution currently.Problem:
My immediate issue was how to get the Windows Phone sqlite database from the installation into the app storage.Solution:
private async Task CopyDatabase(){ bool isDatabaseExisting = false; try { StorageFile storageFile = await ApplicationData.Current.LocalFolder.GetFileAsync("people.db"); isDatabaseExisting = true; } catch { isDatabaseExisting = false; } if (!isDatabaseExisting) { StorageFile databaseFile = await Package.Current.InstalledLocation.GetFileAsync("people.db"); await databaseFile.CopyAsync(ApplicationData.Current.LocalFolder); }}Source:
- http://wp.qmatteoq.com/using-sqlite-in-your-windows-8-metro-style-applications
- http://wp.qmatteoq.com/import-an-already-existing-sqlite-database-in-a-windows-8-application/
Subscribe to:
Posts (Atom)