Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2006, 12:42 PM
Authorized User
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default Strange ERROR (?)

Hi,

I fill in form.htm and send values to the results.asp page...works fine. Then when I click the back button and re-submit the same form details, the results.asp page generates an error.

Error reads something like (from top of my head): cannot add duplicates, index fields, etc'

Any clues or do I need to provide more info?
Thanks

 
Old June 21st, 2006, 03:37 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sounds like you may be adding data to a db and breaking unique constraints on a field there. Very hard to tell from the info so far. Can you post the exact error and the code causing it?

Cheers,

Chris

 
Old June 21st, 2006, 08:21 AM
Authorized User
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Thanks for 'querying' further: Here the resulting error:

.................
Confirmation Page

testing your details have successfully been added to our database.


Microsoft JET Database Engine error '80004005'

The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.

/matconfirm.asp, line 44
......................
How do I prevent this? Hope you can assist. Thanks!


 
Old June 21st, 2006, 08:31 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ok, it does look like a unique constraint issue.

Can you post the code causing the error, please?

Thanks,

Chris

 
Old June 21st, 2006, 10:34 AM
Authorized User
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code causing the error?

Is it not: Microsoft JET Database Engine error '80004005' ?

Or do you need to look at the code of the confirmation page?

Thanks


 
Old June 21st, 2006, 10:38 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yep, need to see the code of the confirmation page, and which line is 44.

Cheers,

Chris

 
Old June 21st, 2006, 10:41 AM
Authorized User
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<%
Dim myCon, cPath, strCon, mySQL, wpage, myValb, myVals, myDate
cPath = Server.MapPath ("access/Matrimony.mdb")
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & cPath & ";"
Set myCon = Server.CreateObject("ADODB.Connection")
    myCon.Open strCon
%>
<head>...

<%
      wpage = LCase(request.ServerVariables("HTTP_REFERER"))
  If InStr(1,wpage,"matsister.asp") Then
    mySQL = "INSERT INTO tbl_sister (SrfName, SrSurname, SrAge, SrStatus, SrEmail, SrPhone, SrTown, SrCountry, SrNational, SrEthnicity, SrPract, SrEducation, SrDawah, SrHijab, SrWork, SrDate, SroDesc)"
    myVals = Replace(request.form("SroDesc"), "'", "''")
    mySQL = mySQL & " VALUES ('" & request.form("SrfName") & "','" & request.form("SrSurname") & "','" & request.form("SrAge") & "','" & request.form("SrStatus") & "','" & request.form("SrEmail") & "','" & request.form("SrPhone") & "','" & request.form("SrTown") & "','" & request.form("SrCountry") & "','" & request.form("SrNational") & "','" & request.form("SrEthnicity") & "','" & request.form("SrPract") & "','" & request.form("SrEducation") & "','" & request.form("SrDawah") & "','" & request.form("SrHijab") & "','" & request.form("SrWork") & "','" & request.form("SrDate") & "','" & myVals & "')"
Response.write ("Sister ") & request.form("SrfName") & (" your details have successfully been added to our database.")
ELSE
    mySQL = "INSERT INTO tbl_brother (BrfName, BrSurname, BrAge, BrStatus, BrEmail, BrPhone, BrTown, BrCountry, BrNational, BrEthnicity, BrEducation, BrPract, BrDawah, BrBeard, BrWork, BrDate, BroDesc)"
    myValb = Replace(request.form("BroDesc"), "'", "''")
mySQL = mySQL & " VALUES ('" & request.form("BrfName") & "','" & request.form("BrSurname") & "','" & request.form("BrAge") & "','" & request.form("BrStatus") & "','" & request.form("BrEmail") & "','" & request.form("BrPhone") & "','" & request.form("BrTown") & "','" & request.form("BrCountry") & "','" & request.form("BrNational") & "','" & request.form("BrEthnicity") & "','" & request.form("BrPract") & "','" & request.form("BrEducation") & "','" & request.form("BrDawah") & "','" & request.form("BrBeard") & "','" & request.form("BrWork") & "','" & request.form("BrDate") & "','" & myValb & "')"

Response.write ("Brother ") & request.form("BrfName") & (" your details have successfully been added to our database.")
End IF
myCon.execute(mySQL) 'line 44
myCon.Close
Set myCon = Nothing
%>

</body>
</html

 
Old June 22nd, 2006, 03:17 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sure, looks like one or more of the fields you are inserting into has a unique constraint on it. Can you tell which from the db - it may be the email one I guess.

Otherwise, you could remove all the fields from your query and then add them in one by one until it fails again to isolate the problem.

Can you add a Response.Write mySQL above line 44 and post the output from that, please.

Cheers,

Chris

 
Old June 22nd, 2006, 03:43 AM
Authorized User
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK:
...............
Confirmation Page

Brother test your details have successfully been added to our database.
INSERT INTO tbl_brother (BrfName, BrSurname, BrAge, BrStatus, BrEmail, BrPhone, BrTown, BrCountry, BrNational, BrEthnicity, BrEducation, BrPract, BrDawah, BrBeard, BrWork, BrDate, BroDesc) VALUES ('test','testing','25','SINGLE','[email protected]','0 1132','Leeds','England','None','None','No','None', 'NO','NO','Studying','6/22/2006','Administrator')

Microsoft JET Database Engine error '80004005'

The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.

/matconfirm.asp, line 45
.................

 
Old June 22nd, 2006, 04:28 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ok, one or more of the fields in your db table tbl_brother has a constraint preventing duplicate entries, remove this constraint if it is not what you want, otherwise run a query to check a matching entry does not exist prior to running your insert query.

HTH,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
strange error Iguchi Visual Studio 2008 1 April 11th, 2008 06:21 AM
An Strange Error alirezaaali Classic ASP Professional 1 August 16th, 2007 10:03 AM
Strange Error !!! NinaWilliam ASP.NET 1.0 and 1.1 Basics 2 May 21st, 2006 01:34 AM
strange error dynamic_iiita Beginning PHP 0 May 22nd, 2005 06:14 AM
Strange error eraser Classic ASP Basics 3 September 21st, 2004 07:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.