Private Function GetDataCount(SQL As String) As Integer Dim itemCount As Integer = 0 Dim con As New SQLiteConnection con.ConnectionString = My.Settings.ConnectionString con.Open() Try 'Create a new SQL command Dim cmd As SQLiteCommand = con.CreateCommand() cmd.CommandText = SQL itemCount = cmd.ExecuteScalar Catch ex As Exception Console.WriteLine(ex.Message) Finally 'Cleanup and close the connection If Not IsNothing(con) Then con.Close() End Try Return itemCount End Function