I used to be fairly proficient with vb and c# but haven't used either of them in 10 or twenty years. I have a need to use sqlite in vb.net (vs2015) but I simply cannot remember (or find out) how to have a generic function read the database and return a result containing multiple rows. Supplying the query is easy but the datareader is unavailable as soon as I close the connection. I think I need to copy the data into a different object and return that but that is all.
Anyone have an example?
This is what I have so far
Anyone have an example?
This is what I have so far
Example:
Public Function ReadDatabase(query As String) As SQLiteDataReader
sqlConn.ConnectionString = dbSource
sqlConn.Open()
sqlCmd.Connection = sqlConn
sqlCmd.CommandText = query
sqlReader = sqlCmd.ExecuteReader()
Using sqlReader
While (sqlReader.Read)
Debug.Print(sqlReader.GetString(1)) '+ " " + sqlReader.GetString(2))
End While
End Using
sqlReader.Close()
sqlConn.Close()
End Function