| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

01-06-04, 18:14
|
|
Registered User
|
|
Join Date: Jan 2004
Location: Sydney
Posts: 11
|
|
ASP code sometimes inserts duplicate entries into Oracle table - why?
|
|
Do you have any idea why my ASP code intermittently inserts duplicate records into my Oracle database? Can it be the code or is it the database at fault?
|
|

01-06-04, 20:24
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 454
|
|
|
wrong with the code
I had this problem before. It happened when something was wrong with the code. It was not related to the database. If you can post your code here that will help me to tell you what is wrong.
|
|

01-07-04, 17:01
|
|
Registered User
|
|
Join Date: Jan 2004
Location: Sydney
Posts: 11
|
|
Here's my code...
|
|
Here is the part of the code that inserts....
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase("KPI", _
"kpiuser/kpiuser", Cint(0))
Set OraDynaset = OraDatabase.CreateDynaset(_
"select * from Transport", cint(0))
OraDatabase.DbExecuteSQL("insert into Transport (ClientName, Location, EntryDate, T1, T2, T3, T4, T5, T6, T7, WEDATE, unique_ID, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, UserName) values ('" & fClientName & "', '" & fLocation & "','" & MediumDate( Now(), "Null" ) & "','" & fT1 & "','" & fT2 & "','" & fT3 & "','" & fT4 & "','" & fT5 & "','" & fT6 & "','" & fT7 & "','" & MediumDate( Session("Date"), "Null" ) & "',id_transport.nextval,'" & fT8 & "','" & fT9 & "','" & fT10 & "','" & fT11 & "','" & fT12 & "','" & fT13 & "','" & fT14 & "','" & fT15 & "','" & fT16 & "','" & fT17 & "','" & fT18 & "','" & fT19 & "','" & Session("MM_Username") & "')")
Thanks for helping.
|
|

01-07-04, 17:51
|
|
Registered User
|
|
Join Date: Feb 2002
Posts: 2,232
|
|
This can also be caused by users who are expecting a faster response when adding records and click multiple times. That may explain the random behavior.
|
|

01-07-04, 21:44
|
|
Registered User
|
|
Join Date: Jan 2004
Location: Sydney
Posts: 11
|
|
Can't be that
I am still developing the application, so there are no other users yet... only me. I cannot figure out what makes it insert 2 records. It just happends randomly.
I am using IIS web server and Oracle 9.2 if that helps. If it's my code I am sure it comes from this page (recorded.asp) this is the whole page:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/Intranet.dwt.asp" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Entry Recorded</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<link href="../../Text.css" rel="stylesheet" type="text/css">
<!-- InstanceEndEditable -->
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td background="/Images/bg_top.gif"><img src="/Images/top_left2.jpg" width="179" height="72"></td>
<td background="/Images/bg_top.gif"><div align="center"><img src="http://10.0.0.60/intranet/Images/top_logo.gif" width="340" height="72"></div></td>
<td background="/Images/bg_top.gif"><div align="right"><img src="/Images/top_right2.jpg" width="179" height="72"></div></td>
</tr>
<tr>
<td colspan="3"><table width="100%" border="0">
<tr bgcolor="#FFFFFF">
<td width="25%" valign="top">
<!-- InstanceBeginEditable name="Menu" -->
<!-- InstanceEndEditable --></td>
<td width="75%"><!-- InstanceBeginEditable name="Main" -->
<div align="center">
<p class="style5">Entry Successful.<br><br>Thank you.</p>
<p class="style5"><a href="AddData.asp">Enter another Transport KPI </a></p>
<p class="style5">or</p>
<p class="style5"><a href="../KPI.asp">Go back to KPI main page </a></p>
</div>
<%
Function MediumDate( ByVal stringToCheck, ByVal defaultOut )
Dim dayPart
Dim monthPart
Dim yearPart
If IsDate( stringToCheck ) Then
dayPart = Day( stringToCheck )
monthPart = Monthname( Month( stringToCheck ), True )
yearPart = Year( stringToCheck )
MediumDate = dayPart & "-" & monthPart & "-" & yearPart
Else
MediumDate = defaultOut
End If
End Function
Session("Location") = request("Location")
Session("Date") = request("Date")
Dim OraDatabase
Dim OraDynaset
fCLIENTNAME=Session("ClientName")
fLOCATION=Session("Location")
fDate=Session("Date")
fT1= request("T1")
fT2 = request("T2")
fT3 = request("T3")
fT4 = request("T4")
fT5 = request("T5")
fT6 = request("T6")
fT7 = request("T7")
fT8 = request("T8")
fT9 = request("T9")
fT10 = request("T10")
fT11 = request("T11")
fT12 = request("T12")
fT13 = request("T13")
fT14 = request("T14")
fT15 = request("T15")
fT16 = request("T16")
fT17 = request("T17")
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase("KPI", _
"kpiuser/kpiuser", Cint(0))
OraDatabase.DbExecuteSQL("insert into Transport (ClientName, Location, EntryDate, T1, T2, T3, T4, T5, T6, T7, WEDATE, unique_ID, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, UserName) values ('" & fClientName & "', '" & fLocation & "','" & MediumDate( Now(), "Null" ) & "','" & fT1 & "','" & fT2 & "','" & fT3 & "','" & fT4 & "','" & fT5 & "','" & fT6 & "','" & fT7 & "','" & MediumDate( Session("Date"), "Null" ) & "',id_transport.nextval,'" & fT8 & "','" & fT9 & "','" & fT10 & "','" & fT11 & "','" & fT12 & "','" & fT13 & "','" & fT14 & "','" & fT15 & "','" & fT16 & "','" & fT17 & "','" & Session("MM_Username") & "')")
varT3=request("T3")
x=1
For x=1 to varT3
fReason_T3=Request.Cookies("Reason_T3_" & x)
fDate_T3=Request.Cookies("Date_T3_" & x)
fConNote_T3=Request.Cookies("ConNote_T3_" & x)
fT3Attempt_T3=Request.Cookies("T3Attempt_" & x)
OraDatabase.DbExecuteSQL("insert into T3 (ID, Attempt, Reason, TDate, CONNOTE) values (id_transport.currval,'"& fT3Attempt_T3 &"','"& fReason_T3 &"','"& MediumDate( fDate_T3, "" ) &"','"& fConNote_T3 &"')")
next
Set OraSession = Nothing
Session.Contents.RemoveAll()
%>
<!-- InstanceEndEditable --></td>
</tr>
</table></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|