I am struggling with some SQLite to VB.net code. I am using sharpdevelop 4.0 to try and connect to a SQLite database using SQLiteadmin. I have set up both and just need help in getting them to connect to each other when they mainform loads. I have put the code in mainform (see below) The database is called "KCB.db3". When i click the button i get an error message saying the connection is closed. What am i doing incorrectly?
Dim SQLconnect As New System.Data.SqlClient.SqlConnection
Dim SQLcommand As System.Data.SqlClient.SqlCommand
Dim SQLreader As System.Data.SqlClient.SqlDataReader
Sub Button1Click(sender As Object, e As EventArgs)
'Procedure to extract records from People table in Contacts SQLite database file
'Create an SQL command
SQLcommand = SQLconnect.CreateCommand
'Create SQL statement
SQLcommand.CommandText = "SELECT * FROM Staff"
'Extract data
SQLreader = SQLcommand.ExecuteReader()
While SQLreader.Read()
'Add record to listbox
msgbox(SQLreader("Staff_ID"))
msgbox(SQLreader("Staff_Surname"))
msgbox(SQLreader("Staff_First_Name"))
End While
'Clear SQL command buffer
SQLcommand.Dispose()
End Sub
Sub MainFormLoad(sender As Object, e As EventArgs)
SQLconnect.ConnectionString = "data source = KCD.db3"
SQLconnect.Open()
End Sub
I hope someone out there can help! Thanks