Inexplicable duplicate inserts and updates using Coldfusion and MS SQL

Discussion in 'Programming' started by jonnyewing, Apr 7, 2010.

  1. #1
    I have been a Coldfusion developer for a decade and I have been having trouble for months with my PC somehow causing SQL inserts and updates to double-up unpredictably.

    This isn't an issue with the code - I have been able to deploy CF websites quite happily without my clients having an trouble. It seems to be something to do with my own computer and it's an intermittent issue - if I start getting duplicate inserts, I can reboot my machine and they'll stop.

    Let me give you an example. I have a form to fill out and post to a basic CFM page with an insert query that should run once and then return me to the form using cflocation. It couldn't be simpler. The SQL table has a primary key with identity specification set to Yes and it increments by one each time a new row is inserted. Again, very basic stuff.

    But for some reason, when I run the code, it will sometimes insert twice. So I'll get row number 1 immediately followed by row number 2, which will be otherwise identical.

    Sometimes it works exactly as you'd expect and it has never, never created three or more identical records - it is only ever two.

    I hasten to add that this isn't just on my local dev set-up (CF8 with MSSQL 2005) - the same thing has happened to me when using live platforms.

    I use Windows 7 right now, but I was getting the same thing with Vista. Also, it happens with both Firefox and IE, so the issue doesn't seem to be browser-bound. It's possible it might not be Coldfusion-related, because I recently signed a petition on ipetitions.com only to discover that my signature had been submitted twice. But that's only anecdotal evidence - there might just have been a glitch on their site that is completely unrelated.

    Has anyone else experienced this? Anyone know what might be causing it or have suggestions for how to trace the cause?

    I'd much appreciate any advice.
     
    jonnyewing, Apr 7, 2010 IP
  2. Oceanus

    Oceanus Member

    Messages:
    903
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Hmm, that's weird. Do you have any toolbars installed?
     
    Oceanus, Apr 17, 2010 IP
  3. jonnyewing

    jonnyewing Member

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    No - good suggestions, but I always avoid those. I use lots of Firefox add-ons, but like I say, when this happens, it affects IE and Firefox and Safari alike.

    Someone has suiggested to me that it might be caused by a faulty mouse.

    That actually seems like a fair suggestion given that I really don't know for sure that it's caused by any particular software. So now I am just waiting for it to happen again - next time it does, I'm going to swap out the mouse for a different one and see if that solves the mystery.
     
    jonnyewing, Apr 19, 2010 IP
  4. BestInsurance

    BestInsurance Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    yeah... you have to replace your mouse. i'd advice you to setup qForms js library and try again. it catches duplicate form submission.
     
    BestInsurance, Apr 22, 2010 IP
  5. jonnyewing

    jonnyewing Member

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #5
    Thanks for the qForms tip.

    It just happened to me again today - filled out a form, clicked the button and I was getting duplicate entries again.

    So I switched the mouse to a different one, tried again and - no change. Still duplicating.

    So I can probably rule out the mouse (maybe I should try a third one just to be sure...?)

    However, I just downloaded qForms and added it to the code I was working on and it worked perfectly. No duplications. Obviously, that's not quite the resolution to all my problems. I still have no idea if this thread belongs in a forum for Coldfusion development or if it's a Windows 7 glitch or a hardware fault, but qForms might become a part of all my development projects from now on.
     
    jonnyewing, May 6, 2010 IP