Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql record being inserted twice. Don't want it to.

Status
Not open for further replies.

timtom

Programmer
Jul 12, 2001
78
GB
Hi. I've got a simple submit form page which works perfectly, except that it inserts the same record twice (but with different auto ids). It only does this the first time I add a record for a particular company, once the duplicate record is in there I can just add records for that company normally. Why would that be? My code is as follows

[red]<%
option explicit
dim objCn, objRs, sSql
%>
<!--#include file = &quot;../includes/db.asp&quot;-->
<%
dim complaint_id, company_qr, complaint_date, complaint, action
dim training_raised, procedural_raised, date_completed, follow_call

company_qr = session(&quot;COMPANY&quot;)
complaint_date = request.form(&quot;txtComplaintDate&quot;)
complaint = request.form(&quot;txtComplaint&quot;)
action = request.form(&quot;txtAction&quot;)
training_raised = request.form(&quot;txtTrainingIssue&quot;)
procedural_raised = request.form(&quot;txtProceduralIssue&quot;)
date_completed = request.form(&quot;txtDateCompleted&quot;)
follow_call = request.form(&quot;txtFollowUpCall&quot;)
call openConnection(objCn)

sSql = &quot;INSERT INTO COMPANY_COMPLAINTS (COMPANY_QR, COMPLAINT_DATE, COMPLAINT, &quot; &_
&quot;ACTION, TRAINING_ISSUE_RAISED, PROCEDURAL_ISSUE_RAISED, DATE_COMPLETED, &quot; &_
&quot;FOLLOW_UP_CALL) VALUES('&quot; & company_qr & &quot;', '&quot; & complaint_date & &quot;', '&quot; &_
complaint & &quot;', '&quot; & action & &quot;', '&quot; & training_raised & &quot;', '&quot; & procedural_raised & &quot;', '&quot; &_
date_completed & &quot;', '&quot; & follow_call & &quot;')&quot;

set objRs = objCn.execute (sSql)

call closeConnection(objCn)
response.redirect &quot;viewcomplaints.asp&quot;
%>[/red]

Or would I be best to post this in the SQL forum? Thanks for help
Cheers
Sarah ;-)
User_timtom.jpg
[sub]WASN'T FIT ENOUGH FOR THE POLICE FORCE[/sub]​
 
This looks fine...doesn't seem as if two inserts should be happening. Has this been resolved? gettin' jiggy wid' it --
smbure
 
Are you doing a post-back to this page? Maybe it's inserting again afterwards.

Chip H.
 
whats ur asp page name?where u check the duplicate records for a company?i think u postback to this page in some where.

wrg
webspy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top