Tuesday, September 20, 2011

C# & SQLite – System.Data.SQLite

Building an VS2010 project using an SQLite embedded database.. Project codename &quotContact&qout; I’ll be demostrating how to insert, edit and delete records from the database First of all you’ll have to aquire a few files and install a few necessary software packets. SQLite ADO.Net pro
  • Building an VS2010 project using an SQLite embedded database
  • Project codename &quotContact&qout;
  • I’ll be demostrating how to insert, edit and delete records from the database
First of all you’ll have to aquire a few files and install a few necessary software packets.

SQLite Admin Tool

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 choze not to register the DLL files. Why 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 ecential 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 to classes to handel all dB transactions..
dBFunctions.cs and dBHelper.cs
Next I added a Folder named "Forms" and created a few forms to handel 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

No comments: