• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Just spent hours chasing down a bug

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Just spent hours chasing down a bug

    Symptoms were that all the data in one table was being updated with the same values.

    Been going round in circles.

    Then saw the following SQL lurking amongst a ton of other SQL:

    UPDATE tableName
    SET col1 = @col1,
    col2 = @col2,
    col3 = @col3
    etc
    WHERE primaryKey = primaryKey;


    The missing @ on primaryKey parameter!



    In the old days before senility and long term alcohol abuse I would have spotted that in seconds.


    #2
    You should have posted the code on here. With thread title "spot the bug competition".

    Comment


      #3
      Stick to VB.NET...

      Comment


        #4
        I couldn't see the wood for the trees. No matter how many times I looked at the update, I didn't see the missing @.

        Time to retire.

        Comment


          #5
          i dont understand why you have such naff column names.
          col1, col2, col3

          is it a database for Colins Cauliflower Collective in Colchester or something


          (\__/)
          (>'.'<)
          ("")("") Born to Drink. Forced to Work

          Comment


            #6
            I'm surprised the etc in the middle of your SQL Statement worked!!

            Comment


              #7
              The best sql update issue is where you update a (few) record(s) based on records from another table. If you're not careful you can update all the records.
              Speaking gibberish on internet talkboards since last Michaelmas. Plus here on Twitter

              Comment


                #8
                Rookie mistake by newbies

                Comment


                  #9
                  Originally posted by Weltchy View Post
                  I'm surprised the etc in the middle of your SQL Statement worked!!
                  It's a surprisingly good name for a function call!
                  Speaking gibberish on internet talkboards since last Michaelmas. Plus here on Twitter

                  Comment


                    #10
                    Easy mistake to make. Perhaps it's worth prefixing parameter variables? Same with method parameters, because one day it will trip you up?

                    Comment

                    Working...
                    X