VB.NET & SQLite Tutorials : how to create a connection to SQLite database using SQLite Ado.NET data , SQLite 3 ODBC driver, .NET Framework as a Data Provider in vb.net
VB.NET & SQLite Tutorials : How to create a connection to SQLite Embedded database using SQLite Ado.NET data , SQLite 3 ODBC driver, .NET Framework as a Data Provider in vb.net? SQLite can handle a connetion from an application like .Net Apps using ADO.NET, ODBC as a Data Provider.
Please read : How to Install SQLite on Windows, Create Database, Table, Columns?
You can follow link above to Download and install SQLite Embedded Database on your computer, If already did, just create your first database using SQLite and we will make a connection from vb.net simple application.
How to create Database, Columns, Field, View, Trigger in SQLite? here simple aplications will help you to Configure your SQLite Embedded Database, "SQL Maestro Group" download from here https://www.sqlmaestro.com/ or use SQLite Administrator, Download Here http://sqliteadmin.orbmu2k.de/
SQL Maestro Group offers complete database management and web development tools for all the most popular DBMS providing the highest performance, scalability and reliability to meet the requirements of today's database applications.
Now, we will create Table names for our SQLite Database (tbl_biodata) to our new database "NewinSQLite" and add more field to your table and click CREATE, see images below :
Or you can use this SQL query to crate "tbl_biodata"
On the Form1.vb, we must add SQLite Library to our project, we can use Nuget Packages to declare SQLite library, Right click on you project solutions > Manage NuGet Packages for Solutions > and search for the "SQLite", than install it. see image below :
If you have finished, just write all source code below to crate connection to SQLite Embedded database using VB.NET
In-Memory Database
Using UTF16
With password
SQLite Version 2.x
Create a New Database
Using Compression
Connection to SQLite using ODBC Driver
Download SQLite Connection full source code here https://www.dropbox.com/s/lmh1z8rtc67295w/hc-kr-com-sqlite-connect.zip?dl=0
Please read : How to Install SQLite on Windows, Create Database, Table, Columns?
You can follow link above to Download and install SQLite Embedded Database on your computer, If already did, just create your first database using SQLite and we will make a connection from vb.net simple application.
How to create Database, Columns, Field, View, Trigger in SQLite? here simple aplications will help you to Configure your SQLite Embedded Database, "SQL Maestro Group" download from here https://www.sqlmaestro.com/ or use SQLite Administrator, Download Here http://sqliteadmin.orbmu2k.de/
SQL Maestro Group offers complete database management and web development tools for all the most popular DBMS providing the highest performance, scalability and reliability to meet the requirements of today's database applications.
Create New Project (SQLite Connection)
Open your visual studio and create new project and rename it with "SQLiteConnection", now after created, leave your project for a moment, we will create a SQLite database for our project.Create SQLite Database (Columns, Field, Value)
On this tutrial, we will create SQLite database using SQLite Administrator, just Open your SQLite Administrator and please create new Databases using new name "NewInSQLite" and Save it into your current project, on this tutorial i'll save my new database in : "C:\Users\b0x\Documents\Visual Studio 2015\Projects\NewApp\NewApp\bin\Debug".Now, we will create Table names for our SQLite Database (tbl_biodata) to our new database "NewinSQLite" and add more field to your table and click CREATE, see images below :
Or you can use this SQL query to crate "tbl_biodata"
CREATE TABLE [tbl_biodata] (
[id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[nama] VARCHAR(50) NULL,
[nis] NVARCHAR(20) NULL,
[kelas] VARCHAR(20) NULL,
[alamat] NVARCHAR(50) NULL
)
Source Code Create Connections to SQLite Database
After you already have a SQLite Database, back to our project in visual studio, we will create a connection to our new database.On the Form1.vb, we must add SQLite Library to our project, we can use Nuget Packages to declare SQLite library, Right click on you project solutions > Manage NuGet Packages for Solutions > and search for the "SQLite", than install it. see image below :
If you have finished, just write all source code below to crate connection to SQLite Embedded database using VB.NET
Imports System.Data.SQLite ' using SQLite Namespaces
Public Class Form1
Dim connect As SQLiteConnection ' declare the connection
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
connection() ' call connection Functions
connect.Close() ' close connection
End Sub
Sub connection()
Try
connect = New SQLiteConnection("Data Source=hc-kr.db") ' Connection DataSource
If connect.State = ConnectionState.Closed Then
connect.Open()
MsgBox("Connection Success!", MsgBoxStyle.Information, "Informations")
End If
Catch ex As Exception
MsgBox("Failed to connect to SQLite Database", MsgBoxStyle.Information, "Warning")
End Try
End Sub
End Class
More String connection to SQLite database :
You can use costum string connection to our connection, see it below :SQLite Connections with .NET Provider
Basic
Connection = "Data Source=c:\mydb.db;Version=3;"
In-Memory Database
Connection = "Data Source=:memory:;Version=3;New=True;"
Using UTF16
Connection = "Data Source=c:\mydb.db;Version=3;UseUTF16Encoding=True;"
With password
Connection = "Data Source=c:\mydb.db;Version=3;Password=myPassword;"
Connect SQLite using ADO.NET
Standard
Connection = "Data Source=c:\mydb.db;Version=3;"
SQLite Version 2.x
Data Source=c:\mydb.db;Version=2;"
Create a New Database
Connection = "Data Source=c:\mydb.db;Version=3;New=True;"
Using Compression
Connection = "Data Source=c:\mydb.db;Version=3;Compress=True;"
Connection to SQLite using ODBC Driver
Connection = "DRIVER=SQLite3 ODBC Driver;Database=c:\mydb.db;LongNames=0;Timeout=1000;NoTXN=0;
SyncPragma=NORMAL;StepAPI=0;"
Download SQLite Connection full source code here https://www.dropbox.com/s/lmh1z8rtc67295w/hc-kr-com-sqlite-connect.zip?dl=0
COMMENTS