Portable database : Sqlite with ASP.net



Problem: Unable to load sqlite.dll
Solution: Add from Nuget package both for x64 and x86

problem: Unable to open database (sqlite) in asp.net
solution : In IIS7 it simply fails with the Unable to open the database file error, ihmo because it tries to write to the Temporary ASP.NET Files folder.. use |DataDirectory| in path like this

   
 


Most of applications we develop on .NET in a professional way use to imply the existence of a database, usually SQL Server, Oracle, DB2 or MySQL. Nevertheless, sometimes, even we need database support, it's not necessary to mantain a database manager, because its portability, licensing, data volume and complexity...

In Android, each application uses a single local SQLite database. Why not applying the same philosophy to a .NET application? Well, it's possible to encapsulate the database in a .db file inside a local directory on the same way Android applications do. Let's see now how to install SQLite for .NET and programming a little application which makes CRUD (Create, Retrieve, Update, Delete) operations over an entity. From there, it will be extrapolated to more complex entitites.

SQLite installation in .NET
First of all: downloading the SQLite library adapted to .NET. We can download it from this website http://system.data.sqlite.org/

You can also use Nuget package installer to get it in visual studio.

Use Sqlite Browser for working on database. http://sqlitebrowser.sourceforge.net/


Comments