Discussion:
Dup entries when creating a new DB entry (ASP Classic with an MDB file)
(too old to reply)
Phillip Windell
2009-12-09 21:46:56 UTC
Permalink
I am having problem with my ASP page creating a new databse record *twice*
when I subnet the page. This creates a duplicate records (except for the
autonumber ID field). They are ASP Classic pages written in VBS. The
database is an MS Access MDB file. Below you will find first a
"Response.write" output of an SQL Statement. Then below that is the code of
the page. The page is fairly short. I can include the relavant parts of
the two "include files" if you need them, but I doubt you will need them.
You should be able to tell from the SQL statement that the previous pages
are working corrrectly.

Thanks
--
Phillip Windell
The views expressed, are my own and not those of my employer, or Microsoft,
or anyone else associated with me, including my cats.
-----------------------------------------------------



--------------------------------SQL Statement---Ignore
line-wrap-------------------------------
INSERT INTO tblEvents (fldTitle, fldStartDate, fldEndDate, fldDetails,
fldApproved) VALUES ('This is a Title', #1/12/2012#, #1/13/2012#, 'This is a
Description', on)

----------------------------------------Page
code-----------------------------------------------
<% @LANGUAGE="VBSCRIPT" %>
<% Option Explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> </TITLE>
<META content="text/html; charset=unicode" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18852"></HEAD>
<BODY>
<!-- #include FILE = "database.asp" -->
<!-- #include FILE = "functionsproceedures.asp" -->
<%
Dim intID
Dim strTitle
Dim strStartDate
Dim strEndDate
Dim strDetails
Dim strApproved
Dim strSQL

strTitle = CleanIllegalChar(Request.Form.Item("txtTitle"))
strStartDate = cDate(Request.Form.Item("txtStartDate"))
strEndDate = cDate(Request.Form.Item("txtEndDate"))
strDetails = CleanIllegalChar(Request.Form.Item("areaDetails"))
strApproved = Request.Form.Item("chkApproved")
If strApproved = "" then strApproved ="False"

'Response.write intID & "<br>"
'Response.write strTitle & "<br>"
'Response.write strStartDate & "<br>"
'Response.write strEndDate & "<br>"
'Response.write strDetails & "<br>"
'Response.write strApproved & "<br>"


'Create SQL string for Update
strSQL = "INSERT INTO tblEvents (fldTitle, fldStartDate, fldEndDate,
fldDetails, fldApproved) "
strSQL = strSQL & "VALUES ("
strSQL = strSQL & "'" & strTitle & "', "
strSQL = strSQL & "#" & strStartDate & "#, "
strSQL = strSQL & "#" & strEndDate & "#, "
strSQL = strSQL & "'" & strDetails & "', "
strSQL = strSQL & "" & strApproved & ""
strSQL = strSQL & ")"
'Write the changes
'Response.write strSQL
'Response.end
objConn.Execute strSQL
set objConn = Nothing
%>
<Input Type="Button" Name="btnDone"
Value="Done"onClick=window.location.href="manage.asp">
</BODY>
</HTML>
Jason Keats
2009-12-10 12:30:19 UTC
Permalink
Post by Phillip Windell
I am having problem with my ASP page creating a new databse record *twice*
when I subnet the page. This creates a duplicate records (except for the
autonumber ID field). They are ASP Classic pages written in VBS. The
database is an MS Access MDB file. Below you will find first a
"Response.write" output of an SQL Statement. Then below that is the code of
the page. The page is fairly short. I can include the relavant parts of
the two "include files" if you need them, but I doubt you will need them.
You should be able to tell from the SQL statement that the previous pages
are working corrrectly.
Thanks
Are you sure someone's not using the Back button, then resubmitting?

Try something like the following to prevent people using the back button...

<%
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "Last-Modified", Now & " GMT"
Response.AddHeader "Cache-Control", "no-store, must-revalidate, private"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
%>

HTH
Phillip Windell
2009-12-10 14:44:05 UTC
Permalink
Post by Jason Keats
Are you sure someone's not using the Back button, then resubmitting?
I'm sure.
It is still in development and I am the only one working with it.
We're using MS Access iteslf as the Management "UI" until I get the Web UI
finished.

It is a complete mystery to me. I have other similar sites and pages that
are following the same scheme,...in fact I borrowed & edited much of the
code from those,...and all of those work fine

This is the workflow process:

Manage.asp---(Lists records and uses a "New Record" link
to)--->NewEntry.asp-->(Fill-in blank form and submit
to)--->NewEntryApply.asp---( writes to the DB and "header-refreshes" or uses
a button)--->Manage.asp

Originally NewEntryApply.asp did a header-refresh back to Manage.asp, but
with this trouble I took it out and used a manual Button,...but that did not
solve the problem. The NewEntry.asp already has the exact "no cache" code
you suggested (right to the letter). I can add it to the NewEntryApply.asp
and see if that helps

Just to have it out there,...here below is the database.asp "include file".
The other "include file" isn't really relevant to what we are looking at.
If you think of anything else that may help let me know

------------Database.asp--------------

<%
Dim strFilePath
Dim objConn
Dim objRs

strFilePath = "C:\inetpub\database\CommCalendar.mdb"

'ADO connection to database
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & strFilePath
Set objRs = Server.CreateObject("ADODB.Recordset")
%>
Phillip Windell
2009-12-10 15:57:24 UTC
Permalink
The entire App is only about 52kb "zipped up"

There is nothing "secret" in it,...I could make the whole thing available in
a Zip file if anyone wants to just see the whole thing.
--
Phillip Windell

The views expressed, are my own and not those of my employer, or Microsoft,
or anyone else associated with me, including my cats.
-----------------------------------------------------
Phillip Windell
2009-12-12 04:05:03 UTC
Permalink
It seems to be a problem with IIS.

I removed and reinstalled IIS and it worked correctly "once",...but on the
second attempt it started creating duplicate records again.

I did a "repair" of the MDAC installation,...that did not help anything.

I copied the ASP files to another machine that had IIS running and it worked
perfectly every time and I tried it multiple times for consistancy.

I'm probably not going to worry about what is wrong with IIS,...I'll
probably just relod the problem Laptop from scratch later when I have time.

.
--
Phillip Windell

The views expressed, are my own and not those of my employer, or Microsoft,
or anyone else associated with me, including my cats.
-----------------------------------------------------
Post by Phillip Windell
The entire App is only about 52kb "zipped up"
There is nothing "secret" in it,...I could make the whole thing available
in a Zip file if anyone wants to just see the whole thing.
--
Phillip Windell
The views expressed, are my own and not those of my employer, or Microsoft,
or anyone else associated with me, including my cats.
-----------------------------------------------------
Phillip Windell
2009-12-12 19:55:14 UTC
Permalink
I have to take back everything I just said. Now the machine I moved it to
is doing the same thing. At first when I moved the file it seems to work
fine,...but today it is creating dupe entries again. I did run Windows
Update on that machine last night after I moved the files,...could some
update have screwed it up???

Is there anyone here? I seem to be talking to myself.
--
Phillip Windell

The views expressed, are my own and not those of my employer, or Microsoft,
or anyone else associated with me, including my cats.
-----------------------------------------------------
Jason Keats
2009-12-13 00:56:07 UTC
Permalink
Post by Phillip Windell
I have to take back everything I just said. Now the machine I moved it to
is doing the same thing. At first when I moved the file it seems to work
fine,...but today it is creating dupe entries again. I did run Windows
Update on that machine last night after I moved the files,...could some
update have screwed it up???
Is there anyone here? I seem to be talking to myself.
Phillip, I sent you an email two days ago saying I would be willing to
have a look at your code. I haven't received a response.
Phillip Windell
2009-12-14 14:51:14 UTC
Permalink
Ok, sorry,..I didn't see it.
That address is a "spam trap",...I don't check it much,....but it does work.
I'll get back with you in a bit. It's Monday morning,...those get a little
busy.
--
Phillip Windell

The views expressed, are my own and not those of my employer, or Microsoft,
or anyone else associated with me, including my cats.
-----------------------------------------------------
Post by Jason Keats
Post by Phillip Windell
I have to take back everything I just said. Now the machine I moved it to
is doing the same thing. At first when I moved the file it seems to work
fine,...but today it is creating dupe entries again. I did run Windows
Update on that machine last night after I moved the files,...could some
update have screwed it up???
Is there anyone here? I seem to be talking to myself.
Phillip, I sent you an email two days ago saying I would be willing to
have a look at your code. I haven't received a response.
Loading...