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 9 m 52 sec
Reputation Power: 10
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: 8
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 9 m 52 sec
Reputation Power: 10
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 9 m 52 sec
Reputation Power: 10
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, 439 views)
File Type: zip GR_RecPartsPopup.zip (2.1 KB, 421 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 9 m 52 sec
Reputation Power: 10
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 9 m 52 sec
Reputation Power: 10
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 9 m 52 sec
Reputation Power: 10
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
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
Brilliant !

Quote:
Originally Posted by 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.




wow.. u are brilliant.. thanks for ur help man!
my page looks fine now !

cheers !

Reply With Quote
  #19  
Old February 10th, 2004, 10:08 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 9 m 52 sec
Reputation Power: 10
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Quote:
Originally Posted by taithinye
exec sp_reset_connection
what is this means ?
I've never seen or used this myself, but here's what google had to say: http://216.239.57.104/search?q=cach...&hl=en&ie=UTF-8

Reply With Quote
  #20  
Old February 10th, 2004, 10:36 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
I've never seen or used this myself, but here's what google had to say: http://216.239.57.104/search?q=cach...&hl=en&ie=UTF-8



thanks

Reply With Quote
  #21  
Old March 21st, 2005, 04:02 PM
imustgo imustgo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 2 imustgo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 33 sec
Reputation Power: 0
solution

I had the same problem with my asp page, but there was no forms in it.

Check your insert methods... I was using dynamic object :

Set rs=Server.CreateObject("ADODB.recordset")
rs.CursorType=adOpenStatic
rs.LockType=3

(...)

and simple static recordset in an "if" statement

Set rs = conn.Execute ("SELECT * FROM tblWhatever")
(..)

When I was using the static recordset "when the if statement were true", all was added twice. I've put ONLY dynamic recordset and everything's fine. Records has been added once. Static & dynamic interaction with your DB at the same time = bad...

Hope that helps you guys
imust

Reply With Quote
  #22  
Old March 21st, 2005, 06:20 PM
imustgo imustgo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 2 imustgo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 33 sec
Reputation Power: 0
http://support.microsoft.com/default.aspx?scid=kb;en-us;264189

This problem is caused by AutoNumbers in your table. Better manage them yourself and make sure they are unique...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Weird SQL bug - INSERT adds 2 records


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
Stay green...Green IT