can you explain how to run this inside application and do not need any connection dll files
just add to any application folder and run database could you explain it how to use as admin and add data delete data and son on
thanks
Imports System.Data.SQLite
Public Class Form1
Private dbPath As String = "Data Source=MyDatabase.sqlite;Version=3;"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
CreateDatabaseAndTable()
InsertData("John Doe", 30)
InsertData("Jane Smith", 25)
ReadData()
End Sub
Private Sub CreateDatabaseAndTable()
Using connection As New SQLiteConnection(dbPath)
connection.Open()
Dim createTableSql As String = "CREATE TABLE IF NOT EXISTS Users (Id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, Age INTEGER)"
Using command As New SQLiteCommand(createTableSql, connection)
command.ExecuteNonQuery()
End Using
End Using
End Sub
Private Sub InsertData(name As String, age As Integer)
Using connection As New SQLiteConnection(dbPath)
connection.Open()
Dim insertSql As String = "INSERT INTO Users (Name, Age) VALUES (@Name, @Age)"
Using command As New SQLiteCommand(insertSql, connection)
command.Parameters.AddWithValue("@Name", name)
command.Parameters.AddWithValue("@Age", age)
command.ExecuteNonQuery()
End Using
End Using
End Sub
Private Sub ReadData()
Using connection As New SQLiteConnection(dbPath)
connection.Open()
Dim selectSql As String = "SELECT Id, Name, Age FROM Users"
Using command As New SQLiteCommand(selectSql, connection)
Using reader As SQLiteDataReader = command.ExecuteReader()
ListBox1.Items.Clear() ' Assuming you have a ListBox named ListBox1
While reader.Read()
Dim id As Integer = reader.GetInt32(0)
Dim name As String = reader.GetString(1)
Dim age As Integer = reader.GetInt32(2)
ListBox1.Items.Add($"ID: {id}, Name: {name}, Age: {age}")
End While
End Using
End Using
End Using
End Sub
End Class