ASP Executes SQL twice ??

Results 1 to 2 of 2

Thread: ASP Executes SQL twice ??

  1. #1
    Join Date
    Dec 1969

    Default ASP Executes SQL twice ??

    Folks,<BR><BR>I have been having a weird problem with my ASP scripts... When I try to<BR>insert a record into an MS-SQL (and oracle) database, sometimes it inserts<BR>the the data twice (i.e. 2 records). and obviously this is not a good thing<BR>and is creating problems.<BR><BR>I however have not been able to recreate the problem consistently, but it<BR>does happen quite often. I have tried to change a couple of setting, tried<BR>putting programming logic etc. but to no avail. Any ideas what could causing<BR>this and what could be done to fix it.<BR><BR>Any help would be appreciated. TIA.<BR><BR>-Raghu<BR><BR>

  2. #2 Guest

    Default Could be re-submit problem

    If your script has only one insert statement and you are getting 2 records added, then could it be that the form is accidentally being submitted twice. This could happen if the page that is doing the insert is refreshed after it has been loaded. If this occurs then the same data that was being submitted would be submitted again. <BR><BR>One way to prevent this would be to have your page, that does the insert, redirect to another page as soon as it has completed the insert. So you would have 3 pages: the form input, the database insert, and the page that shows the result of the process.<BR><BR>Also if there is one of the fields that you don&#039t want duplicated, you should do a select query on the table to see if the value already exists. If the select returns an empty recordset, then you insert the new record. Otherwise you abort.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts