dcsimg
Results 1 to 8 of 8

Thread: How can I show a MessageBox when a database has certain text using SQLite?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2018
    Posts
    49

    How can I show a MessageBox when a database has certain text using SQLite?

    I have an application which reads all of the history off Google Chrome, using SQLite. This is the code I use to do so:


    Code:
    Dim google As String = (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\Google\Chrome\User Data\Default\History")
            Dim fileName As String = DateTime.Now.Ticks.ToString
            File.Copy(google, (Application.StartupPath + ("\" + fileName)))
            Dim con As SQLiteConnection = New SQLiteConnection(("DataSource = " + (Application.StartupPath + ("\" + (fileName + ";Versio=3;New=False;Compress=True;")))))
            Dim da As SQLiteDataAdapter = New SQLiteDataAdapter("select * from urls order by last_visit_time desc", con)
            Dim ds As DataSet = New DataSet
            da.Fill(ds)
            DataGridView1.DataSource = ds.Tables(0)
            con.Close()

    If the database has any certain white listed text, then a MessageBox will show. How can I do this?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,051

    Re: How can I show a MessageBox when a database has certain text using SQLite?

    What indicates that a URL is whitelisted?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2018
    Posts
    49

    Re: How can I show a MessageBox when a database has certain text using SQLite?

    A text file. I want to have a list of whitelisted sites, such as, for example: www.youtube.com.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,051

    Re: How can I show a MessageBox when a database has certain text using SQLite?

    Quote Originally Posted by Modulus View Post
    A text file. I want to have a list of whitelisted sites, such as, for example: www.youtube.com.
    That is not an answer to my question. You are executing a query to retrieve some data. What is it in that data that indicates that a site is whitelisted?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2018
    Posts
    49

    Re: How can I show a MessageBox when a database has certain text using SQLite?

    Quote Originally Posted by jmcilhinney View Post
    That is not an answer to my question. You are executing a query to retrieve some data. What is it in that data that indicates that a site is whitelisted?

    I don't know if this is the right answer, but, I want my program to compare some text in a text file to the data in the database. If there is some data which is the same, a MessageBox shows.

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,051

    Re: How can I show a MessageBox when a database has certain text using SQLite?

    I see. So you're saying that there's nothing in the data itself but you want to check whether each URL in that data is contained in a text file of your own? In that case, read the file into an array by calling File.ReadAllLines. You can then just loop through your data and call Contains on the array, passing the URL.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Member
    Join Date
    Jun 2018
    Posts
    49

    Re: How can I show a MessageBox when a database has certain text using SQLite?

    Quote Originally Posted by jmcilhinney View Post
    I see. So you're saying that there's nothing in the data itself but you want to check whether each URL in that data is contained in a text file of your own? In that case, read the file into an array by calling File.ReadAllLines. You can then just loop through your data and call Contains on the array, passing the URL.

    I'm a newbie at VB.Net, could you link me to a reference? Thanks.

  8. #8
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,051

    Re: How can I show a MessageBox when a database has certain text using SQLite?

    What does that even mean? You want me to provide a link to somewhere that some has already written code that you can copy and paste? How about you take a bit of time to think about what I've said and see if you can do something for yourself before just assuming you can't. There's nothing especially complex there and you can search for yourself to find information about each individual part as required.

    First things first, you've got a DataTable containing the URLs. Can you loop through that and get each URL in turn? Have you even tried? If you can, that's the first step done. If you can't, have you searched the web for information on how to access data in a DataTable?

    Once that step is out of the way, the next thing to do would be to read the data from the file into an array. I told exactly how to do that and, again, if you need more information then you can quite easily search for it yourself, given that I told you exactly what method to call.

    Etc. Don't just sit on your hands and wait for information to find you. If someone points you in a direction then go in that direction. Do what you can for yourself first and then, if you encounter an actual issue, ask about that issue specifically.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width