Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Sql inserts duplicated

Sql inserts duplicated

Scheduled Pinned Locked Moved C#
databasecsharpsaleshelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GermanDM
    wrote on last edited by
    #1

    Hi there, Im sitting with some weird problem here, ok here goes: Well i have a queries application and users select files from a folder list and adds them to a customer they searched for. The file they selected the file path with a subject and note gets saved to the database. Problem is that some times the exact same file path, subject and note gets inserted twice into the database and some times 3 times. I have searched line by line to find any possibility that the insert function runs more than ones but it doesnt. the user select a file then enters a subject and note and then presses the capture button and the data gets inserted. My prodecure only gets executed once and it executes fast so there is no time to maybe click the button twice and even if they did i have a confirm box first before it executes the insert function. :doh: Does anyone know what the problem might be? Pls :(( If you need any more info or code just lemme know. Im programming in VS2005 C# and its a web application. Thanks :)

    C G 2 Replies Last reply
    0
    • G GermanDM

      Hi there, Im sitting with some weird problem here, ok here goes: Well i have a queries application and users select files from a folder list and adds them to a customer they searched for. The file they selected the file path with a subject and note gets saved to the database. Problem is that some times the exact same file path, subject and note gets inserted twice into the database and some times 3 times. I have searched line by line to find any possibility that the insert function runs more than ones but it doesnt. the user select a file then enters a subject and note and then presses the capture button and the data gets inserted. My prodecure only gets executed once and it executes fast so there is no time to maybe click the button twice and even if they did i have a confirm box first before it executes the insert function. :doh: Does anyone know what the problem might be? Pls :(( If you need any more info or code just lemme know. Im programming in VS2005 C# and its a web application. Thanks :)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Well, either the code is being called more than once, or there's a trigger on the database that also runs and does an insert. There is no other possible explantion, unless there's something weird in the SQL itself that can cause it to double insert, but that seems unlikely.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • G GermanDM

        Hi there, Im sitting with some weird problem here, ok here goes: Well i have a queries application and users select files from a folder list and adds them to a customer they searched for. The file they selected the file path with a subject and note gets saved to the database. Problem is that some times the exact same file path, subject and note gets inserted twice into the database and some times 3 times. I have searched line by line to find any possibility that the insert function runs more than ones but it doesnt. the user select a file then enters a subject and note and then presses the capture button and the data gets inserted. My prodecure only gets executed once and it executes fast so there is no time to maybe click the button twice and even if they did i have a confirm box first before it executes the insert function. :doh: Does anyone know what the problem might be? Pls :(( If you need any more info or code just lemme know. Im programming in VS2005 C# and its a web application. Thanks :)

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        A regular insert query doesn't add multiple records. The code is executed more than once, and the probable cause is that a user manages to send multiple requests. Regardless of how fast the response time is, there is almost always a possibility to click the submit button more than once. After the page has been posted to the server, the page remains in the browser until the response comes from the server. Put a script in the page that stops it from being posted more than once:

        <script type="text/javascript">
        var stopped = false;
        </script>

        <input type="submit" onclick="var s=stopped;stopped=true;return s;" />

        --- single minded; short sighted; long gone;

        G 1 Reply Last reply
        0
        • G Guffa

          A regular insert query doesn't add multiple records. The code is executed more than once, and the probable cause is that a user manages to send multiple requests. Regardless of how fast the response time is, there is almost always a possibility to click the submit button more than once. After the page has been posted to the server, the page remains in the browser until the response comes from the server. Put a script in the page that stops it from being posted more than once:

          <script type="text/javascript">
          var stopped = false;
          </script>

          <input type="submit" onclick="var s=stopped;stopped=true;return s;" />

          --- single minded; short sighted; long gone;

          G Offline
          G Offline
          GermanDM
          wrote on last edited by
          #4

          How can I add this script to my page when I already have the button click event from server side in the onClick event in my asp code? Am not very familiar with adding javascript code within a server side C#/ASP.Net web application. Thanks

          G 1 Reply Last reply
          0
          • G GermanDM

            How can I add this script to my page when I already have the button click event from server side in the onClick event in my asp code? Am not very familiar with adding javascript code within a server side C#/ASP.Net web application. Thanks

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            Use the OnClientClick property.

            --- single minded; short sighted; long gone;

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups