Click here to Skip to main content
6,293,171 members and growing! (12,240 online)
Email Password   helpLost your password?
Database » Database » SQL Server     Intermediate

Simple C# Wrapper for SQLite

By fbelic

An article that describes lightweight C# wrapper for SQLite
C# 2.0, Windows, .NET 2.0, Visual Studio, DBA, Dev
Posted:16 Aug 2007
Views:27,698
Bookmarked:23 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
10 votes for this article.
Popularity: 2.58 Rating: 2.58 out of 5
4 votes, 40.0%
1

2

3
4 votes, 40.0%
4
2 votes, 20.0%
5

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


Member

Occupation: Software Developer (Junior)
Location: Croatia Croatia

Other popular Database articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 17 of 17 (Total in Forum: 17) (Refresh)FirstPrevNext
GeneralA possible alternative; NFileStorage Pinmembersnip17:54 17 Mar '09  
Generalcreate a database PinmemberChaozzster7:28 16 Feb '09  
GeneralRe: create a database Pinmemberthk_sompi13:16 1 Mar '09  
GeneralRe: create a database PinmemberKen Eucker10:25 3 Jun '09  
GeneralRe: create a database Pinmemberfbelic0:14 4 Jun '09  
GeneralRe: create a database PinmemberKen Eucker22:19 4 Jun '09  
Generalout of memory Pinmembersaifsail9:32 24 Jan '09  
GeneralPossible memory leak PinmemberJacky__E4:34 24 Nov '08  
GeneralRe: Possible memory leak [modified] Pinmemberoren.shnitzer11:21 22 Dec '08  
GeneralRe: Possible memory leak PinmemberJacky__E4:16 23 Dec '08  
GeneralSame Error PinmemberMember 33120559:50 21 Sep '08  
GeneralRe: Same Error PinmemberMember 331205510:21 21 Sep '08  
Generalfacing some bug with your dll Pinmemberchal_adiera23:42 27 Aug '08  
GeneralCan I use it in my Media Player? PinmemberSukhjinder_K1:58 4 Jan '08  
GeneralVery Nice & Easy to Use PinmemberSukhjinder_K22:22 15 Nov '07  
AnswerRe: Very Nice & Easy to Use PinmemberJacky__E4:18 23 Dec '08  
GeneralThanks for this class Pinmemberflangset1:02 29 Aug '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 16 Aug 2007
Editor: Sean Ewington
Copyright 2007 by fbelic
Everything else Copyright © CodeProject, 1999-2009
Web11 | Advertise on the Code Project