Connecting SQLite with VB.net


Connecting SQLite with VB.net

Connecting SQLite with VB.net


Imports System.Data
Imports System.Data.SQLite
Public Class frmDB
Dim cons As New SQLite.SQLiteConnection
Dim cmd As New SQLite.SQLiteCommand
Dim sql As String
Dim strSQL As String
Dim dss As New DataSet
Dim das As New SQLite.SQLiteDataAdapter
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
SQLiteConnection.CreateFile("C:\SQLite_VB.net_Test\mydatabase.db")
cons.ConnectionString = "Data Source=C:\SQLite_VB.net_Test\mydatabase.db; Version=3"
strSQL = "create table Ramya(Elename varchar(50))"
cons.Open()
das = New SQLite.SQLiteDataAdapter(strSQL, cons)
das.Fill(dss, "ramya")
cons.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
cons.ConnectionString = "Data Source=C:\SQLite_VB.net_Test\mydatabase.db; Version=3"
cons.Open()
cmd = cons.CreateCommand()
cmd.CommandText = "INSERT INTO Ramya VALUES('Microsoft')"
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
cmd.Dispose()
cons.Close()
MsgBox("New record added to the database")
End Sub
End Class


Comments

Guest Author: Principio Tudisco13 Sep 2012

But if encrypted sql database how make building string connection with vb.net ?

Guest Author: Principio Tudisco13 Sep 2012

But if the sqlite database is encrypted, how do I make a connection?

Guest Author: Leandro09 Apr 2013

Hi!, thanks for the code! Can u tell me how to retrieve all information loaded in database?



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: