I was storing my SQLite DB name in App.config and using System.Configuration Reference to retrieve the DB name
I decided this was of no value so I removed the readConfig code
Now I can not create the DB and its two tables
Would someone be kind enough to review the code below and explain what I am doing wrong?
Setting in Module
Public gv_dbName As String = "Notes.db"
Declarations top level on frmStart
Public connStr As String = "Data Source={0};Version=3;"
Public conn As SqliteConnection
Dim cmd As SqliteCommand
Other Relevant Code
Private Sub frmStart_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath)
connStr = String.Format(connStr, gv_dbName)
If My.Computer.FileSystem.FileExists(gv_dbName) Then
btnCreate.Visible = False
btnToEnterData.Visible = True
btnToViewParentTable.Visible = True
ElseIf Not My.Computer.FileSystem.FileExists(gv_dbName) Then
conn = New SqliteConnection($"Data Source = '{gv_dbName}';Version=3;")
tbMessage.Text = "Created Database & Tables"
End If
End Sub
Private Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click
makeDB()
End Sub
Public Sub makeDB()
If Not My.Computer.FileSystem.FileExists(gv_dbName) Then
Try
conn = New SqliteConnection($"Data Source = '{gv_dbName}';Version=3;")
conn.Open()
makeParentTable()
makeChildTable()
conn.Close()
Catch ex As Exception
tbMessage.Text = "Database NOT Created"
End Try
End If
End Sub
I even tried this top level of frmStart
'Friend gv_dbName As String = "Notes.db"
Here is what I based this code off of
Link to Code