|
 |
access_asp thread: form update error
Message #1 by djjens@p... on Mon, 22 Jul 2002 00:25:25
|
|
I get this error after my users hit the submit button, i'm an ASP newbie
please help.
here is the error and the code.
thanks in advance, this is a bunch so I really do appreciate any help.
DJ Jensen
Microsoft JET Database Engine (0x80040E21)
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.
'the code
<%
OPTION EXPLICIT
dim objConn
%>
<!-- #include file="datastore.asp" -->
<!-- METADATA TYPE="typelib"
File="C:\Program Files\Common
Files\System\ado\msado15.dll" -->
<%
dim dlChoice, userType
dlChoice = Request.Form("dlChoice")
userType = Request.Form("userType")
Select Case userType
Case "VAR"
Call Partners
Case "SP"
Call Partners
Case "Reseller"
Call Partners
Case "MSP"
Call Partners
End Select
Select Case dlChoice
Case "Download"
Call Downloads
Case "Evaluation"
Call Downloads
End Select
Sub Downloads
'''''''''' Insert Records into the database ''''''''''
Dim objRS, intIDForNewRecord
Set objRS = Server.CreateObject("ADODB.Recordset") '
establish connection to database
objRS.Open "gaspDownloads", objConn, adOpenStatic, adLockOptimistic,
adCmdTableDirect
'''''''''' Insert Records into the database ''''''''''
objRS.MoveLast
objRS.AddNew
objRS("Source") = "www.domain.com"
objRS("Date") = Date
objRS("ContactName") = Request.Form("userName")
objRS("Title") = Request.Form("userTitle")
objRS("Department") = Request.Form("userDept")
objRS("CompanyName") = Request.Form("userCompany")
objRS("Address1") = Request.Form("userAddress")
objRS("Address2") = Request.Form("userAddress2")
objRS("City") = Request.Form("userCity")
objRS("State") = Request.Form("usState")
objRS("Province") = Request.Form("worldState")
objRS("Country") = Request.Form("userCountry")
objRS("Zip") = Request.Form("userZip")
objRS("Phone") = Request.Form("userPhone")
objRS("Fax") = Request.Form("userFax")
objRS("WebAddress") = Request.Form("userWebaddress")
objRS("Email") = Request.Form("userEmail")
objRS("userType") = Request.Form("userPosition")
objRS("DecisionMaker") = Request.Form("purchDecision")
objRS("EmployeeType") = Request.Form("emplType")
objRS("Interest") = Request.Form("userInterest")
objRS("Quantity") = Request.Form("numComps")
objRS("HowHear") = Request.Form("howHear")
objRS("ProductChoice") = Request.Form("product_choice")
objRS("ReceiveChoice") = Request.Form("dlChoice")
objRS.Update
objRS.Close
Set objRS = Nothing
If Request.Form("product_choice") = "GASP6" THEN
%><!--#include file="dl_thanks.asp"--><%
ElseIf Request.Form("product_choice") = "GASP6ev" THEN
%><!--#include file="ev_thanks_g6.asp"--><%
ElseIf Request.Form("product_choice") = "GASP6plus" THEN
%><!--#include file="ev_thanks_g6p.asp"--><%
ElseIf Request.Form("product_choice") = "GASP6enterprise" THEN
%><!--#include file="ev_thanks_g6e.asp"--><%
ElseIf Request.Form("product_choice") = "GASP-Mac" THEN
%><!--#include file="dl_mac_thanks.asp"--><%
End If
'''''''''' Close Database Connection ''''''''''
dim Mailer
dim Mailer2
dim Subject
dim userData
IF Request.Form("dlChoice") = "Download" THEN
DIM bodyText
bodyText = "Dear "& Request.Form("userName") &","&vbCR&vbCR&vbCR&"Thank
you for downloading an evaluation copy of the product6? suite, the premier
PC asset and software management program published by domain Systems,
Inc."&vbCR&vbCR&vbCR&"GASP® is an easy to use, fast, flexible and
extremely accurate tool for gaining control of your PC software and
hardware assets. productgives the most comprehensive inventory of PC
applications available today with the industry's largest Software
Identification Database (SID®)."&vbCR&vbCR&vbCR&"To help you get started
we have included the product6 Getting Started Guide in PDF format. There
are also extensive Help Files built into the program. Use of the
evaluation program is subject to the terms and conditions of domain System
Inc.'s Standard License Agreement. The demo you have includes all of the
functions of the full release of GASP. It is, however, restricted to the
processing of 25 PCs. Please note that the online version may not have the
most up-to-date SID."
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "domain Systems, Inc."
Mailer.FromAddress = "download@d..."
Mailer.RemoteHost = "mail.domain.com;ns1.m-1.net;mail.m-1.net"
Mailer.AddRecipient Request.Form("userName"), Request.Form
("userEmail")
Mailer.Subject = "Thank you for downloading GASP®"
Mailer.BodyText = bodyText
IF Mailer.SendMail() THEN
Response.Write("")
ELSE
Response.Write("Mail Failure, please contact <A
HREF='mailto:webmaster@d...'>webmaster@d...</A>")
End IF
userData = "Customer Name: "& Request.Form("userName") &vbCR&"Customer
Title: "& Request.Form("userTitle") &vbCR&"Company Name: "&
Request.Form("userCompany") &vbCR&"Department: "& Request.Form
("userDept") &vbCR&"Email Address: "& Request.Form("userEmail")
&vbCR&"Phone Number: "& Request.Form("userPhone") &vbCR&"Fax Number: "&
Request.Form("userFax") &vbCR&"Address: "& Request.Form("userAddress")
&vbCR&"Address Cont: "& Request.Form("userAddress2") &vbCR&"City: "&
Request.Form("userCity") &vbCR&"State: "& Request.Form("usState")
&vbCR&"Zip Code: "& Request.Form("userZip") &vbCR&"Country: "&
Request.Form("userCountry") &vbCR&"Web Address: "& Request.Form
("userWebAddress") &vbCR&"Heard about us: "& Request.Form("howHear")
&vbCR&"Number of Computers: "& Request.Form("numComps") &vbCR&"I am the
following: "& Request.Form("emplType") &vbCR&"Type of Job: "& Request.Form
("userPosition") &vbCR&"Buying Decision: "& Request.Form("purchDecision")
&vbCR&"User Interest: "& Request.Form("userInterest") &vbCR&"Product: "&
Request.Form("product_choice")
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "domain Sales"
Mailer.FromAddress = "sales@d..."
Mailer.RemoteHost = "mail.domsin.com;ns1.m-1.net;mail.m-1.net"
Mailer.AddRecipient Request.Form("userName"), "download@d..."
Mailer.Subject = "Download For "& Request.Form("userCompany")
Mailer.BodyText = userData
IF Mailer.SendMail() THEN
Response.Write("")
ELSE
Response.Write("Mail Failure1, please contact <A
HREF='mailto:webmaster@d...'>webmaster@d...</A>")
End IF
ElseIF Request.Form("dlChoice") = "Evaluation" THEN
' Choose which email to send
dim pChoice
pChoice = Request.Form("product_choice")
DIM bodyTextShip
Select Case pChoice
Case "GASP6ev"
bodyTextShip = "Dear "& Request.Form("userName")
&","&vbCR&vbCR&vbCR&"Thank you for requesting an evaluation copy of the
product6? suite, the premier PC asset and software management program from
domain Systems, Inc. An domain representative will contact you shortly to
arrange shipment of the evaluation CD."&vbCR&vbCR&vbCR&"productis an easy
to use, fast, flexible and extremely accurate tool for gaining control of
your PC software and hardware assets.
Case "GASP6enterprise"
bodyTextShip = "Dear "& Request.Form("userName")
&","&vbCR&vbCR&vbCR&"Thank you for requesting an evaluation copy of the
product6 Enterprise? suite, the premier PC asset and software management
program from domain Systems, Inc. An domain representative will contact
you shortly to arrange shipment of the evaluation CD.
Case "GASP6plus"
bodyTextShip = "Dear "& Request.Form("userName")
&","&vbCR&vbCR&vbCR&"Thank you for requesting an evaluation copy of the
product6 Plus? suite, the premier PC asset and software management program
from domain Systems, Inc. An domain representative will contact you
shortly to arrange shipment of the evaluation
CD."&vbCR&vbCR&vbCR&"productis an easy to use, fast, flexible and
extremely accurate tool for gaining control of your PC software and
hardware assets.
End Select
Set Mailer2 = Server.CreateObject("SMTPsvg.Mailer")
Mailer2.FromName = "domain Sales"
Mailer2.FromAddress = "sales@d..."
Mailer2.RemoteHost = "mail.domain.com;ns1.m-1.net;mail.m-1.net"
Mailer2.AddRecipient Request.Form("userName"), Request.Form
("userEmail"), "download@d..."
Mailer2.Subject = "Thank you for your interest in ourpoduct®"
Mailer2.BodyText = bodyTextShip
IF Mailer2.SendMail() THEN
Response.Write("")
ELSE
Response.Write("Mail Failure2, please contact <A
HREF='mailto:webmaster@d...'>webmaster@d...</A>")
End IF
userData = "Customer Name: "& Request.Form("userName") &vbCR&"Customer
Title: "& Request.Form("userTitle") &vbCR&"Company Name: "&
Request.Form("userCompany") &vbCR&"Department: "& Request.Form
("userDept") &vbCR&"Email Address: "& Request.Form("userEmail")
&vbCR&"Phone Number: "& Request.Form("userPhone") &vbCR&"Fax Number: "&
Request.Form("userFax") &vbCR&"Address: "& Request.Form("userAddress")
&vbCR&"Address Cont: "& Request.Form("userAddress2") &vbCR&"City: "&
Request.Form("userCity") &vbCR&"State: "& Request.Form("usState")
&vbCR&"Zip Code: "& Request.Form("userZip") &vbCR&"Country: "&
Request.Form("userCountry") &vbCR&"Web Address: "& Request.Form
("userWebAddress") &vbCR&"Heard about us: "& Request.Form("howHear")
&vbCR&"Number of Computers: "& Request.Form("numComps") &vbCR&"I am the
following: "& Request.Form("emplType") &vbCR&"Type of Job: "& Request.Form
("userPosition") &vbCR&"Buying Decision: "& Request.Form("purchDecision")
&vbCR&"User Interest: "& Request.Form("userInterest") &vbCR&"Product: "&
Request.Form("product_choice")
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "productDownloads"
Mailer.FromAddress = "download@d..."
Mailer.RemoteHost = "mail.domain.com;ns1.m-1.net;mail.m-1.net"
Mailer.AddRecipient Request.Form("userName"), "download@d..."
Mailer.Subject = "Download For "& Request.Form("userCompany")
Mailer.BodyText = userData
IF Mailer.SendMail() THEN
Response.Write("")
ELSE
Response.Write("Mail Failure1, please contact <A
HREF='mailto:webmaster@d...'>webmaster@d...</A>")
End IF
End If
End Sub
Sub Partners
'''''''''' Open Partners Database Connection ''''''''''
Dim objRS, intIDForNewRecord
Set objRS = Server.CreateObject("ADODB.Recordset") '
establish connection to database
objRS.Open "Partners", objConn, adOpenStatic, adLockOptimistic,
adCmdTableDirect
'''''''''' Insert Records into the database ''''''''''
objRS.MoveLast
intIDForNewRecord = objRS("ID") +1
objRS.AddNew
objRS("ID") = intIDForNewRecord
objRS("Date") = Date
objRS("PartnerType") = Request.Form("userType")
objRS("Name") = Request.Form("userName")
objRS("Title") = Request.Form("userTitle")
objRS("Department") = Request.Form("userDept")
objRS("Company") = Request.Form("userCompany")
objRS("Address1") = Request.Form("userAddress")
objRS("Address2") = Request.Form("userAddress2")
objRS("City") = Request.Form("userCity")
objRS("State") = Request.Form("usState")
objRS("StateIntl") = Request.Form("worldState")
objRS("Country") = Request.Form("userCountry")
objRS("Zip") = Request.Form("userZip")
objRS("Phone") = Request.Form("userPhone")
objRS("Fax") = Request.Form("userFax")
objRS("WebAddress") = Request.Form("userWebaddress")
objRS("Email") = Request.Form("userEmail")
objRS("CmpnyDescrip") = Request.Form("cmpnyDscrp")
objRS("NumEmpl") = Request.Form("user_employees")
objRS("NumEmplSales") = Request.Form("user_employees_sales")
objRS("NumEmplTech") = Request.Form("user_employees_tech")
objRS("NumOfcsWrld") = Request.Form("user_offices_worldwide")
objRS("NumOfcsUs") = Request.Form("user_offices_us")
objRS("SrvcsDescrip") = Request.Form("user_describe0")
objRS("YrsInBusiness") = Request.Form("user_years")
objRS("Revenue") = Request.Form("user_revenue")
objRS("RevenueHw") = Request.Form("user_revenue_hardware")
objRS("RevenueSw") = Request.Form("user_revenue_software")
objRS.Update
objRS.Close
Set objRS = Nothing
DIM Autotext, FromName, FromField, Subject, Mailer, Mailer2
FromName = "My Co." + ", Inc."
FromField = "user@d..."
Subject = "Thank you for filling out our Questionnaire"
Autotext = "Dear Prospective Partner,"&vbCR&vbCR&"Thank you for
your interest in the domain Partnership Programs. If you have not already
done so, please download an evaluation version of the actual product6
suite from our website: www.domain.com and try it out. "
' Send AutoResponse
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = FromName
Mailer.FromAddress = FromField
Mailer.RemoteHost = "mail.domain.com;ns1.m-l.net;mail.m-l.net"
Mailer.AddRecipient Request.Form("userName"), Request.Form("userEmail")
Mailer.Subject = Subject
Mailer.BodyText = Autotext
IF Mailer.SendMail() THEN
Response.Write("")
ELSE
Response.Write("Mail failure. Check tcp/ip
connection...\n")
End IF
%><!--#include file="pt_thanks.asp"--><%
'''''''''' Close Database Connection ''''''''''
End Sub
%>
Message #2 by "Ken Schaefer" <ken@a...> on Mon, 22 Jul 2002 11:48:49 +1000
|
|
Sorry if this sounds patronising, but it seems painfully obvious from the
error message that you are attempting to add a record that has a duplicate
value for the primary key to a record that already exists in the table.
Primary keys need to be unique - they are how the database keeps track of
which records are which. As such they are a database concept, not an ASP
concept.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <djjens@p...>
Subject: [access_asp] form update error
: I get this error after my users hit the submit button, i'm an ASP newbie
: please help.
:
: here is the error and the code.
:
: thanks in advance, this is a bunch so I really do appreciate any help.
:
: DJ Jensen
:
:
: Microsoft JET Database Engine (0x80040E21)
: 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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
 |