Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 10th, 2002, 03:29 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Angry Weird SQL bug - INSERT adds 2 records

Hi guys,

I experienceing a really weird bug at the moment. When I perform an insert, 2 records get added! (PS - I am using an ASP web interface.)

Both records are identical, except for their key (incrementing INT's), obviously.

I am using the same bit of code I always use successfully everywhere else. I've gone over everything, but I can find no trace of an extra execute statement or anything anywhere...

Anyone else experienced this before, or any ideas on what could be causing this??

thanks,

craig

Reply With Quote
  #2  
Old August 11th, 2002, 06:25 AM
James Yang James Yang is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Atlanta, Georgia
Posts: 284 James Yang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 45 sec
Reputation Power: 7
Send a message via ICQ to James Yang
are u using sql server 2000 ? if so use profiler to check that ur asp page isn't inserting the record 2 times.
__________________
Regards,

James Yang
.NET Developer / Network Engineer
MCSE, MCDBA, MCSA, CCNA

http://www.yellowpin.com/
http://www.opentechsupport.com/

Reply With Quote
  #3  
Old August 12th, 2002, 12:19 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
hmm, if i were you, try commenting out the line that inserts the records, and run the script, if it still adds a record, then your got another query somewhere?

Reply With Quote
  #4  
Old August 12th, 2002, 05:39 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Agghhhhh

figured it out...


<input type="image" onclick="document.frmDetails.submit()"> is the culprit. By default the IMAGE INPUT type is a submit button. I also had code in the onclick attribute submitting the form. Two submits!!!!!

what a bugger

Reply With Quote
  #5  
Old December 17th, 2002, 02:55 PM
floorbiz floorbiz is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 2 floorbiz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Weird SQL bug - INSERT adds 2 records

I just started to experience the same problem. I looked over the code and don't find anything wrong.

I have had the same exact code for 2 years with no problem.

Reply With Quote
  #6  
Old February 10th, 2004, 02:03 AM
taithinye taithinye is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 11 taithinye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i have use the profiler.. i can see the statement is executed 2 times..

how to rectify this ?

Reply With Quote
  #7  
Old February 10th, 2004, 02:11 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Show us the code you are using to execute the statement (and the form) - maybe it's being submitted twice like mine was.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #8  
Old February 10th, 2004, 02:18 AM
taithinye taithinye is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 11 taithinye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i attached the code

GR_RecPartsPopupUpdate
- insert statement is here

GR_RecPartsPopup.zip
- 20 rows of entry with check box for each one..
- only checked entry will be inserted to database
Attached Files
File Type: zip GR_RecPartsPopupUpdate.zip (1.0 KB, 379 views)
File Type: zip GR_RecPartsPopup.zip (2.1 KB, 358 views)

Reply With Quote
  #9  
Old February 10th, 2004, 02:26 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Your counter checkbox doesn't seem to set to the value "on". Your popupupdate code only runs on rows that are checked. Does that sound right?

Reply With Quote
  #10  
Old February 10th, 2004, 02:27 AM
taithinye taithinye is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 11 taithinye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
checkbox setup

yeap.. it is true

Reply With Quote
  #11  
Old February 10th, 2004, 02:29 AM
taithinye taithinye is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 11 taithinye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
solution

so do u have any solution for this ?

Reply With Quote
  #12  
Old February 10th, 2004, 06:07 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Um - yes, add 'value="on"' (without the single quotes) into your checkbox.

Reply With Quote
  #13  
Old February 10th, 2004, 08:41 PM
taithinye taithinye is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 11 taithinye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by stumpy
Um - yes, add 'value="on"' (without the single quotes) into your checkbox.



already add value=on. but the same error happen again

Reply With Quote
  #14  
Old February 10th, 2004, 09:31 PM
taithinye taithinye is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 11 taithinye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
weird problem

the first page if i click received parts that link to second page (update page)
and when first time update it will insert two times
but after first time update, on the same page (second page) i click refresh button it will insert 1 time

Reply With Quote
  #15  
Old February 10th, 2004, 09:42 PM
taithinye taithinye is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 11 taithinye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sql profiler

i am using profiler to check the updating process

when come to first page i click the received part button that link to second page.. and on second page if i update the parts it will insert twice and when i continue on the same page i click refresh button it will insert one time..

in the profiler i noticed that the first update on second page
the insert statement running smoothly but after the last record inserted it display
Event Class - RPC:Completed
TextData - exec sp_reset_connection
then it perform the same insert statement again..

but when i click the refresh button
the profiler shows only once the insert statement without
the event class and textdata as i mentioned (RPC:Completed, exec_sp_reset_connection

can anyone help me on this problem ?
i just wan the data to be inserted one time only

Reply With Quote
  #16  
Old February 10th, 2004, 09:47 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Figured it out! - it's essentially the same problem as I was having. The form is being submitted twice.
Change your validation function so that it only returns true, and does NOT submit the form. That's what the submit button is for.

Reply With Quote
  #17  
Old February 10th, 2004, 09:52 PM
taithinye taithinye is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 11 taithinye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
exec sp_reset_connection

exec sp_reset_connection

what is this means ?

Reply With Quote
  #18  
Old February 10th, 2004, 10:00 PM
<