Results 1 to 4 of 4

Thread: urgent help needed: mysql/sql database, checking for duplicates/adding line

  1. #1

    Thread Starter
    Addicted Member jalexander's Avatar
    Join Date
    Jan 2011
    Location
    Memphis, TN
    Posts
    160

    Red face urgent help needed: mysql/sql database, checking for duplicates/adding line

    Let's call my program FortuneSender.exe, it's made to send Fortune cookie messages to my forum members. Currently it sends 1 fortune to each member per month via forum PM function. They have to contact me VIA pm requesting it. Sometimes members request multiple fortunes per-month & they are only allowed to receive one. So to be sure my program does not send more than 1 to the same forum user, I incorporated the following subs into my program, it creates a blacklist of usernames I've already sent a fortune to this month......I am looking for a better way, more 'real time' way of doing this, so if i need to run multiple programs, from different locations at the same time, I don't end up sending more than 1 to 1 person.

    Code:
    Private FortuneBlacklist As New List(Of String)
    
        Private Sub SaveFortuneBlacklist(ByVal fileLoc As String)
            IO.File.WriteAllLines(fileLoc, Blacklist.ToArray) 'writes all the entries of FortuneBlacklist to array... line by line to a file
        End Sub
    
        Private Sub RetrieveFortuneBlacklist(ByVal filepath As String)
            FortuneBlacklist.AddRange(IO.File.ReadAllLines(filepath)) 'loads the blacklist into memory
        End Sub
    
        On Form_Load I call on...
         RetrieveFortuneBlacklist("FortuneBlacklist.txt")
    
         Then in Form_Closed I call on....
         SaveFortuneBlacklist("FortuneBlacklist.txt")
    
        And during the main function of "SEND_FORTUNE"......I start it out with this........before going on with the forum PM function
                Dim username As String =  some html code on my forum
                If Not FortuneBlacklist.Contains(username) Then
                FortuneBlacklist.Add(username)
    This worked perfectly when running 1 program....however, I want to be able to run it on more of my forums, run more copies of it etc. And I need this FortuneBlacklist to be in real time, instead of relying on its own starting array. I want it to be in real time. So what I need to do is to set up this same function, VIA sql/mysql/or a database of sorts, on my webserver. So that both of my programs, no matter where/when i run them, will all be checking/adding to the same DB/or list. Can someone show me a simple way to perform the functions above using MYSQL/SQL or some sort of db/file i can use on my webserver. So that instead of relying on it's own "internal array" after loading/and saving when finished. It constantly refreshes the FortuneBlacklist array from the database/and also saves it's newest added username to the database in real time, instead of when it's finished. That way none of the programs running have any chance of sending a PM to the same user twice. Now I know nothing about mysql/sql, I do know how to set up a database though on a webserver. However it would be just as easy for me to do it with a text file on a webpage, via php etc. So i just need a basic idea of how I can accomplish this.

    EDIT: Just had an idea, but don't know how to do this........
    Or could I simply host FortuneBlacklist.txt at C:\FortuneBlacklist.txt, & before each send.....load the text to blacklist.array, then upon sending, add just the 1 (latest line) to the blacklist. That way either program running isn't accidentally re-saving (it's own version) of the entire blacklist at any given time, which may not contain the user name program2.exe just added 1 second previous?
    How do you write just the most recent line in an array to the next available blank line in a text file, that another program may have just added its own line to? I.E. it won't know which line to add to by keeping count of how many lines its written, instead it would need to know to write to whatever the last line in the file is.
    Last edited by jalexander; Mar 22nd, 2013 at 03:16 PM.
    dim jenn as geek = true
    Learning ~ Visual Basic 2010 ~ in free time between college/work -
    currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
    have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
    i am totally super motivated & promise to make an effffin amazing protege!!! #swag

    | -_-_- -_-_- |
    ...W.T..F!?.....
    ||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||

  2. #2

    Thread Starter
    Addicted Member jalexander's Avatar
    Join Date
    Jan 2011
    Location
    Memphis, TN
    Posts
    160
    dupe
    Last edited by jalexander; Mar 22nd, 2013 at 03:17 PM. Reason: sorry duplicate
    dim jenn as geek = true
    Learning ~ Visual Basic 2010 ~ in free time between college/work -
    currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
    have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
    i am totally super motivated & promise to make an effffin amazing protege!!! #swag

    | -_-_- -_-_- |
    ...W.T..F!?.....
    ||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||

  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: urgent help needed: mysql/sql database, checking for duplicates/adding line

    You'll first need to determine what databases can be hosted by your webserver. Not all webhosts provide a database server.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  4. #4

    Thread Starter
    Addicted Member jalexander's Avatar
    Join Date
    Jan 2011
    Location
    Memphis, TN
    Posts
    160

    Re: urgent help needed: mysql/sql database, checking for duplicates/adding line

    Quote Originally Posted by dunfiddlin View Post
    You'll first need to determine what databases can be hosted by your webserver. Not all webhosts provide a database server.
    It has Mysql databases available for sure.
    dim jenn as geek = true
    Learning ~ Visual Basic 2010 ~ in free time between college/work -
    currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
    have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
    i am totally super motivated & promise to make an effffin amazing protege!!! #swag

    | -_-_- -_-_- |
    ...W.T..F!?.....
    ||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||

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
  •  



Click Here to Expand Forum to Full Width