Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Error Message

Status
Not open for further replies.

Ammodog

Technical User
Dec 13, 2002
97
0
0
US
Hello All , I have set up a intranet with DW built in login and password set up. I am using a access database to store the security and have set the user Id to no duplicates. What I need to know is that if a person registers with a duplicate Id how can I tell them that on a warning or other page. Right now they get the Microsoft OLE DB Provider for ODBC Drivers error '80040e14' instead. I will include the script from the page. Thanks!

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/Employeecenter.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form1") Then

MM_editConnection = MM_Employeecenter_STRING
MM_editTable = "tblsecurity"
MM_editRedirectUrl = "registrationsuccessful.asp"
MM_fieldsStr = "fname|value|lname|value|ss|value|phonenum|value|email|value|loginid|value|password|value|secretquestion|value|Answer|value"
MM_columnsStr = "fname|',none,''|lname|',none,''|ss|',none,''|phonenum|',none,''|email|',none,''|loginid|',none,''|password|',none,''|secretquestion|',none,''|Answer|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim rereg
Dim rereg_numRows

Set rereg = Server.CreateObject("ADODB.Recordset")
rereg.ActiveConnection = MM_Employeecenter_STRING
rereg.Source = "SELECT * FROM tblsecurity"
rereg.CursorType = 0
rereg.CursorLocation = 2
rereg.LockType = 1
rereg.Open()

rereg_numRows = 0
%>
<%
Dim resecquest
Dim resecquest_numRows

Set resecquest = Server.CreateObject("ADODB.Recordset")
resecquest.ActiveConnection = MM_Employeecenter_STRING
resecquest.Source = "SELECT * FROM tblsecretquestion"
resecquest.CursorType = 0
resecquest.CursorLocation = 2
resecquest.LockType = 1
resecquest.Open()

resecquest_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<title>Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>

<body link="#000080" vlink="#000080" alink="#800000" background="images/bg_blue2.gif">

<div align="center">
<table border="0" width="750" cellspacing="0" cellpadding="0">
<tr>
<td width="753" colspan="3">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="116">
<p align="left"><img border="0" src="images/Top_llogo2.gif" width="116" height="70"></td>
<center>
<td width="517" bgcolor="#003187" background="images/Temp_toplines.gif">
<p align="center" style="margin-left: 5"><b><font face="Arial" color="#CCCCCC" size="5">&nbsp;
Johnson County Intranet </font></b></td>
</center>
<td width="10" valign="top" bgcolor="#003187">
<p align="right"></td>
<td width="116" valign="top"><img border="0" src="images/Top_nlogo2.gif" width="116" height="70"></td>
</tr>
<tr>
<td width="116" bgcolor="#003187">&nbsp; </td>
<td width="517" bgcolor="#003187" background="images/striations_sm.gif">&nbsp;
</td>
<td width="10" valign="top" bgcolor="#003187">&nbsp;
</td>
<td width="116" valign="top" bgcolor="#003187">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<center>
</center>
<tr>
<td width="753" colspan="3">
<table border="0" width="765" cellspacing="0" cellpadding="3" style="border-left: 1 solid #000000; border-right: 1 solid #000000" height="396">
<tr>
<td width="1" bgcolor="#CCCCCC" height="21">&nbsp;</td>
<td width="168" bgcolor="#CCCCCC" height="30" valign="middle"><font face="Arial" size="2"><b>Registration</b></font></td>
<td width="1" bgcolor="#CCCCCC" valign="middle" height="30">&nbsp;</td>
<td width="545" bgcolor="#CCCCCC" valign="middle" height="35"><div align="center"><b><font face="Arial" size="3"><b>Please Fill Out All Fields</b></font></b> </div></td>
<td width="18" bgcolor="#CCCCCC" height="21">&nbsp;</td>
</tr>
<tr>
<td width="1" bgcolor="#CCCCCC" style="border-top: 1 solid #000000" height="9">&nbsp;</td>
<td width="168" bgcolor="#CCCCCC" style="border-top: 1 solid #000000" height="9">&nbsp;</td>
<td width="1" bgcolor="#FFFFFF" valign="top" style="border-top: 1 solid #000000" height="9">&nbsp;</td>
<td width="545" bgcolor="#FFFFFF" valign="top" style="border-top: 1 solid #000000" height="9">&nbsp;</td>
<td width="18" bgcolor="#FFFFFF" style="border-top: 1 solid #000000" height="9">&nbsp;</td>
</tr>
<tr>
<td width="1" bgcolor="#CCCCCC" rowspan="2" height="321">&nbsp;</td>
<td width="168" bgcolor="#CCCCCC" valign="top" height="294">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" height="25"><b></b></td>
</tr>
<tr>
<td width="100%" height="25">&nbsp;</td>
</tr>
<tr>
<td width="100%" height="25">&nbsp;</td>
</tr>
<tr>
<td width="100%" height="25">&nbsp;</td>
</tr>
<tr>
<td width="100%" height="25">&nbsp;</td>
</tr>
<tr>
<td width="100%" height="20"></td>
</tr>
<tr>
<td width="100%" height="25"><font face="Arial" size="2">&nbsp;</font></td>
</tr>
<tr>
<td width="100%" height="35">


<p>&nbsp;</p></td>
</tr>
<tr>
<td width="100%" height="25"><p>
</form>
</td>
</tr>
<tr>
<td width="100%" height="20"></td>
</tr>
<tr>
<td width="100%" height="25"></td>
</tr>
<tr>
<td width="100%" height="25"></td>
</tr>
<tr>
<td width="100%" height="25"></td>
</tr>
<tr>
<td width="100%" height="25"></td>
</tr>
</table>
</td>
<td width="1" bgcolor="#FFFFFF" valign="top" height="294">&nbsp;</td>
<td width="545" bgcolor="#FFFFFF" valign="top" height="294">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" height="25"><div align="center"><font face="Arial" size="3"></font></div></td>
</tr>
<tr>
<td width="100%"><form action="<%=MM_editAction%>" method="POST" name="form1" onSubmit="MM_validateForm('fname','','R','lname','','R','phonenum','','R','email','','RisEmail','loginid','','R','Answer','','R','ss','','RisNum','password','','R');return document.MM_returnValue">
<table width="499" border="0" align="center">
<tr>
<td width="180"><div align="right"><strong>First Name</strong></div></td>
<td width="309"><div align="left">
<input name="fname" type="text" id="fname" size="30">
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Last Name </strong></div></td>
<td><div align="left">
<input name="lname" type="text" id="lname" size="30">
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Social Security Number </strong></div></td>
<td><p align="left">
<input name="ss" type="password" id="ss" size="20" maxlength="9">
</p>
</td>
</tr>
<tr>
<td colspan="2"><div align="center" class="style1">Example: 123654897 &quot;No Dashes&quot;</div></td>
</tr>
<tr>
<td><div align="right"><strong>Phone Number </strong></div></td>
<td><div align="left">
<input name="phonenum" type="text" id="phonenum" size="20">
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Email Address </strong></div></td>
<td><div align="left">
<input name="email" type="text" id="email" size="30">
</div></td>
</tr>
<tr>
<td><div align="right"><strong>User ID </strong></div></td>
<td><div align="left">
<input name="loginid" type="text" id="loginid" size="30">
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Password</strong></div></td>
<td><div align="left">
<input name="password" type="password" id="password" size="30">
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Secret Question
</strong> </div>
<div align="center">
</div></td>
<td><div align="left">
<select name="secretquestion" id="secretquestion">
<%
While (NOT resecquest.EOF)
%>
<option value="<%=(resecquest.Fields.Item("secretquestion").Value)%>"><%=(resecquest.Fields.Item("secretquestion").Value)%></option>
<%
resecquest.MoveNext()
Wend
If (resecquest.CursorType > 0) Then
resecquest.MoveFirst
Else
resecquest.Requery
End If
%>
</select>
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Answer
</strong></div></td>
<td><div align="left">
<input name="Answer" type="text" id="Answer" size="40">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>

<input type="hidden" name="MM_insert" value="form1">
</form></td>
</tr>
</table>
<p><font size="2" face="Arial"><br>
<span class="style1">* All fields are required! </span></font>
</td>
<td width="18" bgcolor="#FFFFFF" height="294">&nbsp;</td>
</tr>
<tr>
<td width="168" bgcolor="#CCCCCC" height="21">&nbsp;</td>
<td width="1" bgcolor="#FFFFFF" valign="top" height="21">
<p></td>
<td width="545" bgcolor="#FFFFFF" valign="top" height="21">&nbsp;
</td>
<td width="18" bgcolor="#FFFFFF" height="21">&nbsp;</td>
</tr>
<tr>
<td width="1" bgcolor="#CCCCCC" height="21">&nbsp;</td>
<td width="168" bgcolor="#CCCCCC" height="21">&nbsp;</td>
<td width="1" bgcolor="#FFFFFF" valign="top" height="21">&nbsp;
</td>
<td width="545" bgcolor="#FFFFFF" valign="top" height="21">
<font face="Arial" size="1">This site is
maintained by <a href="placeholder.htm">Computer Services </a>.
Last updated <!--webbot bot="Timestamp" S-Type="EDITED"
S-Format="%m/%d/%Y" startspan -->
03/01/05<!--webbot bot="Timestamp" endspan i-CheckSum="12501" --></font></td>
<td width="18" bgcolor="#FFFFFF" height="21">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="79"><img border="0" src="images/btm_left_corner.gif"></td>
<td width="650" bgcolor="#003187">
<p align="center"><font size="1" face="Arial" color="#FFFFFF">Copyright
2003 Johnson County Government &nbsp;&nbsp;&nbsp; For Internal Use Only</font></td>
<td width="75"><img border="0" src="images/btm_right_corner.gif"></td>
</tr>
</table>
</div>

</body>

</html>
<%
rereg.Close()
Set rereg = Nothing
%>
<%
resecquest.Close()
Set resecquest = Nothing
%>



Christopher Abney
There is no limit to the good you can do if you dont care who gets the credit
 
Before ypu insert the new user, run a query to see if that userid already exists in the database. If it does, then direct appropriately, else run the insert.



Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top