Sql inserts duplicated
-
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 :)
-
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 :)
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 )
-
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 :)
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;
-
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;
-
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