Please need help with this error... Urgent | Newbie | | Join Date: Sep 2008
Posts: 2
| |
I am a .NET programmer and i had recently got a web application designed in Classic ASP, to make some modifications.
When i run the application and try to create a new user the following error pops up. "The email address you entered already exists."
Now my problem is i am not able to find out the where the error is generating or why as the datdabase table is completely empty (no records)
Below is the code...
++++++++++++++++++ -
<%
-
Dim action 'After validations the request is sent to here with action value as 1
-
action = Request.QueryString("action")
-
-
Select Case (action)
-
Case "1"
-
Dim objConnection, objRecordset, SQLs, strUserID
-
Dim strPassword, strFname, strLname, strAddress, strCity, strCountry
-
Dim strZip, strUserType, strJoinDate, strEducation, strNewsletter, strEmail, strCareer
-
-
Set objConnection = Server.CreateObject("ADODB.Connection")
-
Set objRecordset = Server.CreateObject("ADODB.Recordset")
-
objConnection.Open Application("ConnectionString")
-
-
strUserType= 0
-
-
strFname=Replace((Request.Form("firstname")),"'", "")
-
strLname=Replace((Request.Form("lastname")),"'", "")
-
strAddress=Replace((Request.Form("address")),"'", "")
-
strCity=Replace((Request.Form("city")),"'", "")
-
strZip=Replace((Request.Form("zip")),"'", "")
-
strCountry=Replace((Request.Form("country")),"'", "")
-
strEmail=Replace((Request.Form("emailaddress")),"'", "")
-
strPassword=Replace((Request.Form("password")),"'", "")
-
strCareer=Replace((Request.Form("careerlevel")),"'", "")
-
strEducation=Replace((Request.Form("education")),"'", "")
-
strJoinDate=(Request.Form("joindate"))
-
strNewsletter=(CInt(Request.Form("newsletter")))
-
-
If strNewsletter <> 1 Then
-
strNewletter = 0
-
End If
-
' ## ERROR CONTROL ##
-
objConnection.Errors.Clear
-
On Error Resume Next
-
SQLs = "INSERT INTO Users (Email, Fname, Lname, UsrPassword, Address, City, Country, Zip, " & _
-
"CareerLevel, Education, JoinDate, " &_
-
"Newsletter, UserType) "
-
SQLs = SQLs & "VALUES ("
-
SQLs = SQLs & "'" & strEmail & "',"
-
SQLs = SQLs & " '" & strFname & "',"
-
SQLs = SQLs & " '" & strLname & "',"
-
SQLs = SQLs & " '" & strPassword & "',"
-
SQLs = SQLs & " '" & strAddress & "',"
-
SQLs = SQLs & " '" & strCity & "',"
-
SQLs = SQLs & " " & strCountry & ","
-
SQLs = SQLs & " '" & strZip & "',"
-
SQLs = SQLs & " '" & strCareer & "',"
-
SQLs = SQLs & " '" & strEducation & "',"
-
SQLs = SQLs & " '" & strJoinDate & "',"
-
SQLs = SQLs & " '" & strNewsletter & "',"
-
SQLs = SQLs & " " & strUserType & ")"
-
-
Application.Lock
-
objConnection.Execute(SQLs) 'Expected Error
-
Application.Unlock
-
-
' ## ERROR CONTROL ##
-
On Error GoTo 0
-
For Each oops In objConnection.Errors
-
-
If oops.number = -2147467259 Then
-
Session("Session_Message") = "The email address you entered already exists. <br />" & _
-
"<a href=""/jobs/forgotpass.asp"">Forgot password? Click here</a>" '& oops.description Error Message
-
Dim strQueryString
-
strQueryString = "?firstname=" & strFname & "&lastname=" & strLname & "&address=" & strAddress & _
-
"&city=" & strCity & "&zip=" & strZip & "&emailaddress=" & strEmail
-
-
Response.Redirect("/jobs/candidate/contactinfo.asp" & strQueryString)
-
Response.End()
-
Else
-
Response.Write "Unexpected error: " & oops.number & " -- " & oops.description & SQLs
-
-
Response.End()
-
End If
-
Next
-
-
-
-
Set objRecordset = objConnection.Execute("SELECT @@IDENTITY")
-
strUserID = objRecordset(0)
-
objConnection.Close
-
Set objRecordset = Nothing
-
-
LoginUser (strUserID)
-
-
Session("Session_Message") = "Welcome " & Session("User_Name")
-
-
If Session("UserLoggedIn") = true Then
-
Response.Redirect("/jobs/candidate/default.asp")
-
End If
-
++++++++++++++++++
Points in bold are for easy identification please ignore them...
I am sure on the working and no idea what does the error number (-2147467259) represents.
Please help me in this regard.
Thank You...
|  | Expert | | Join Date: Feb 2008
Posts: 414
| | | re: Please need help with this error... Urgent
The logic of the code is flawed.
If the database is returning -2147467259 that does not necessarily mean a unique key violation. It could mean any number of things. Google Search
So the first thing you should do is figure out why the database is returning that. My guess is that either you have the database open exclusively (if its Access) or you have some kind of other connectivity issue if its another database type.
| | Newbie | | Join Date: Sep 2008
Posts: 3
| | | re: Please need help with this error... Urgent
i am new with ASP and i really wish i could help..seeing your codes put smiles on my face like am the one writing it..i don't know if u can help me out with the ASP.NET commands and their meaning..thanx alot
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: Please need help with this error... Urgent
Jeff is right. I would suggest you start by commenting out the "on error resume next" line, so you can see what the actual error is and what line is throwing it.
Jared
|  | Similar ASP / Active Server Pages bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,419 network members.
|