- Building a VS2010 project using an SQLite embedded database
- Project codename "
Contact
" - I’ll be demonstrating how to insert, edit and delete records from the database
First of all, you’ll have to acquire a few files and install a few necessary software packets.
SQLite Admin Tool
For this tool, I chose the full install and I’m pleased with the result.
SQLite ADO.Net Provider
This tool I installed in a C:\Temp file and I chose not to register the DLL files. This is because I just needed to include the main DLL in my project.
First, we create a SQLite dB named "Contact.3db" using the SQLite Admin tool. I added a table "Contact
" with a few fields and inserted a few records of data to play with.
CREATE TABLE [Contact] (
[contact_id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
[FirstName] vARCHAR(50) NULL,
[LastName] vARCHAR(50) NULL)
Next I created a VS2010 project named "Contact
" and added a few folders and files:
- Add a folder[Database] and insert an existing Item "
Contact.3db
" - Change the property "Copy to Output Directory" -> "Copy Always"
Next, I added the essential SQLite DLL to my project.
System.Data.SQLite.dll -> change the property "Copy to Output Directory" -> "Copy Always"
SQLite.Interop.dll -> change the property "Copy to Output Directory" -> "Copy Always"
Remark: Both files [System.Data.SQLite.dll , SQLite.Interop.dll] must be included just under the root project "Contact
".
Contact
-> System.Data.SQLite.dll -> SQLite.Interop.dll
Next, I added a folder named "Classes" and created two classes to handle all dB transactions:dBFunctions.cs and dBHelper.cs.
Next, I added a folder named "Forms" and created a few forms to handle Interaction / Interface
ContactList.cs, BaseContact.cs, NewContact.cs, EditContact.cs, DeleteContact.cs.
And this includes my files within my project.
You can download the source code here.
For a more details, show and tell [screenshots & code samples], you can read this article on CodeProject.