Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 15th, 2004, 05:46 AM
emmab emmab is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 emmab User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Code inserting some records twice

Hello, thank you for taking time to read this post...I hope someone can help.

I am working on an online survey, the problem is that my SQL query is inserting some entries twice.
This survey is for members only so therefore require you to login ( so I can capture their membership number)

The problem is the Membership Number is being inserted into the database(one record - membership number, no survey answers) as soon as the survey page is opened.

When all of the survey questions are answered the Membership number and the responses are entered as a new record (one record - Membership number and survey answers)

I am trying to use an if statement but the code is not to be working.

Here is my code:
<%
dim sSQL,sConnString,mSQL, SubmitFlag
pos=Request.form("pos")
contract=Request.form("contract")
.......

If SubmitFlag =1
Then
sSQL="INSERT INTO wage (CompanyId,pos,contract,service,basic, bonus, total,car, pension, category) " & _
"VALUES ('" & MemNo & "','" & pos & "', '" & contract & "', '" & service & "', '" & basic & "', " & _
"'" & bonus & "','" & total & "','" & car & "','" & pension & "', 'Workshop')"
objConn.execute(sSQL)
'close the object and free up resources
objConn.Close
Set objConn = Nothing
End if
%>

//HTML Code

<form name="form1" method="post" action="">
<input type="hidden" name="SumbitFlag" value="1">

Thank you for your help, hope I have explained it clearly enough!!

Reply With Quote
  #2  
Old July 15th, 2004, 06:08 AM
emmab emmab is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 emmab User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Im sorry I put this post in the wrong place should be in SQL Development.

Reply With Quote
  #3  
Old July 15th, 2004, 06:50 AM
Kris_Vanherck's Avatar
Kris_Vanherck Kris_Vanherck is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Belgium, Antwerp
Posts: 177 Kris_Vanherck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 sec
Reputation Power: 5
i think this should be in the programming section: i see no problem with your SQL statement, this is a programming problem, probaly the code running twice because of some circumstance

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Code inserting some records twice


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT