Click here to Skip to main content
Licence 
First Posted 16 Aug 2007
Views 75,529
Downloads 1,963
Bookmarked 52 times

Simple C# Wrapper for SQLite

By | 16 Aug 2007 | Article
An article that describes lightweight C# wrapper for SQLite

Introduction

This article describes a very simple wrapper class for SQLite. This class provides only few simple functions: opening and closing database, returning the list of tables and executing queries. Although these are basic functions, they are enough for someone who needs only a storage engine for his/her program.

Background

While writing this class, I've been using ADO.NET Data Provider for SQLite as a reference, which I found here.

Using the Code

Using this class is very easy: add a reference to this DLL (Project->AddReference...) in your project and a line to your code:

using SQLWrapper;

Now you can start using database functions in your program.

Example:

// creates a new instance of SQLiteBase and opens database in file "test.db"
SQLiteBase db = new SQLiteBase("test.db");
// executes SELECT query and store results in new data table
DataTable table = db.ExecuteQuery("SELECT * FROM table1 WHERE id = 1;");
// closes the database
db.CloseDatabase();

Source Code

There are two constructors and and five public functions:

  • OpenDatabase
  • CloseDatabase
  • GetTables
  • ExecuteNonQuery
  • ExecuteQuery

which are all well-documented in the source file, so I don't see a point in explaining them again.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

fbelic

Software Developer (Junior)

Croatia Croatia

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralEtrow Exception PinmemberAl Baikr21:30 16 Jul '10  
Rant[My vote of 2] Not reacting to malformed queries PinmemberRobhol12:44 5 Jul '10  
GeneralUpdate for Net 4.0 [modified] Pinmemberanss12321:04 6 Jun '10  
GeneralRe: Update for Net 4.0 Pinmemberupsfeup4:24 7 Jul '10  
GeneralRe: Update for Net 4.0 Pinmemberanss1233:59 27 Aug '10  
GeneralHaving Error: library routine called out of sequence Pinmemberupsfeup2:44 26 May '10  
GeneralRe: Having Error: library routine called out of sequence Pinmemberanss1233:02 4 Jun '10  
GeneralMy Sincerest THANKS!! Pinmemberkidzopa16:12 15 May '10  
GeneralA possible alternative; NFileStorage Pinmembersnip16:54 17 Mar '09  
Generalcreate a database PinmemberChaozzster6:28 16 Feb '09  
GeneralRe: create a database Pinmemberthk_sompi12:16 1 Mar '09  
GeneralRe: create a database PinmemberKen Eucker9:25 3 Jun '09  
GeneralRe: create a database Pinmemberfbelic23:14 3 Jun '09  
GeneralRe: create a database PinmemberKen Eucker21:19 4 Jun '09  
Generalout of memory Pinmembersaifsail8:32 24 Jan '09  
GeneralPossible memory leak PinmemberJacky__E3:34 24 Nov '08  
GeneralRe: Possible memory leak [modified] Pinmemberoren.shnitzer10:21 22 Dec '08  
GeneralRe: Possible memory leak PinmemberJacky__E3:16 23 Dec '08  
GeneralNo more memory leak PinmemberSten Hjelmqvist2:19 23 Sep '09  
GeneralRe: Possible memory leak Pinmemberkidzopa16:28 15 May '10  
GeneralSame Error PinmemberMember 33120558:50 21 Sep '08  
GeneralRe: Same Error PinmemberMember 33120559:21 21 Sep '08  
Figured it out... go to http://www.sqlite.org/sqlite-3_6_2.zip[^] and download the sqlite3.dll. Place this in the bin\debug folder and you'll be away.
Generalfacing some bug with your dll Pinmemberchal_adiera22:42 27 Aug '08  
QuestionCan I use it in my Media Player? PinmemberSukhjinder_K0:58 4 Jan '08  
GeneralVery Nice & Easy to Use PinmemberSukhjinder_K21:22 15 Nov '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120604.1 | Last Updated 16 Aug 2007
Article Copyright 2007 by fbelic
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid