SQLite

Posts 1–6 of 6 · Page 1 of 1
SQLite

Introducing you to SQLite

What is SQLite?

SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain.

This is a LOCAL database.

When am I supposed to use this?

SQLite is great if you want to save a lot of data locally. Let's say you have 10 listboxes for different settings each with about 50 entrys. Now you sure don't want to have 10 textfiles containing that data. Furthermore, SQLite allows you to instantly sort the entrys on retreiving using SQL commands(ORDER BY).

Where do I get SQLite?

SQLite Installer

How do I setup a SQLite project?

Simply add the System.Data.SQLite library as reference to your project.
I'm not going to explain you how to add a reference to your project, you should know this by now.

Now simply import System.Data.SQLite as namespace and you are done.

In order to make your project work on other computers, you will have to include the SQLite library within the same folder
or embedd the library into your executeable. You can just do the following:

Project -> References

Set the library's CopyLocal property to True.



On the next debugging, the library will be put in the same directory the program is debugged in.


Usage - Creating/Inserting/Retreiving

To help you understand SQLite I'm going to show you a sample project. The project handles the following:

A user can submit notes and retreive them.

This will not be advanced at all, it should just give you a brief overlook.

To handle the notes, let's first declare a structure.

[highlight="VB.Net"]Public Structure Note
Dim Title As String
Dim Note As String
End Structure[/highlight]

Besides, we need to declare a connection and import System.Data.SQLite and System.IO.

[highlight="VB.Net"]Imports System.Data.SQLite
Imports System.IO

Private SQLConn As New SQLiteConnection[/highlight]

We first off need to create a table in the database.

An empty database is created upon connecting to the database, if the file does not exist yet.

The default SQLite format is .db3.



As for creating tables, there sure are other types rather than TEXT. Date, BLOB etc. Look it up.

We need a function to insert the note:



A function to check if the entry already exists:



And we also need a function to retreive the notes:



This should give you a brief look on the usage of SQLite.

Ofc updating, sorting etc. works aswell. But you should find that out on your own.

Want to know more?

Just try it out on your own. You may always look in the SQLite Documentation.

Thanks for reading, hope you guys understood this.
Nice Tutorial. Thanked ;]
Blubb when are you gonna learn not to interface sql with vb.net??

sql to php and use vb with php make's things so much more secure.
Quote Originally Posted by cosconub View Post
Blubb when are you gonna learn not to interface sql with vb.net??

sql to php and use vb with php make's things so much more secure.
This has NOTHING to do with MySQL or "real" SQL. This is NOT online. Seems like you didn't read the tutorial at all, sad.

I'm always using PHP when working with MySQL/ODBC in VB.Net.
Lol yes sir i did not read Lesson Learned But keep that in mind
:P

Btw love the tut
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Need help?