Fejl hvis man opretter 2 ens brugere !!!
Denne fejl kommer hvis man forsøger oprettet en bruger med samme navn - den er sat til at 2 e-mails ikke må være ens !!------
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] 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.
/info/add_user.asp, line 86
------------------
<%
Dim stMode
stMode = request("mode")
Dim DirPath, MDBPath, DBPath, connect
DirPath = Request.serverVariables("APPL_PHYSICAL_PATH")
MDBPath = "../database/users.mdb"
DBPath = Dirpath & MDBPath
Set Connect = server.createobject("ADODB.connection")
Connect.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & DBPath
Dim browser
browser = request.serverVariables("HTTP_USER_AGENT")
If stMode = "addUser" then
Dim stusername, stpost, stby, stcpr, stemail, stmobiltelefon
stusername = request("userName")
stemail = request("email")
stpost = request("post")
stby = request("by")
stcpr = request("cpr")
stemail = request("email")
stmobiltelefon = request("mobiltelefon")
Dim validateForm, username, email, by, post, cpr, mobiltelefon, nameCheck, checkNameRs, sqlCheckName
validateForm = "validated"
If len(stUserName) < 3 OR len(stUserName) > 20 then
validateForm = "invalid"
userName = "error"
end if
If len(stby) > 20 then
validateForm = "invalid"
by = "error"
end if
If len(stcpr) > 6 then
validateForm = "invalid"
by = "error"
end if
If len(stpost) > 4 then
validateForm = "invalid"
by = "error"
end if
If len(stmobiltelefon) > 8 then
validateForm = "invalid"
telefon = "error"
end if
If len(stemail) > 20 then
validateForm = "invalid"
email = "error"
end if
Set checkNameRs = Server.CreateObject("ADODB.Recordset")
sqlCheckName = "SELECT [email] FROM tblUsers WHERE [email] = '" & stemail & "';"
checkNameRs.Open sqlCheckName, Connect
If not checkNameRs.eof then
validateForm = "invalid"
nameCheck = "error"
end if
If validateForm = "validated" then
Dim sqlAddUser
sqlAddUser = "INSERT INTO tblUsers ([username], [by], [Post], [Cpr], [mobiltelefon], [email]) VALUES('" & stusername & "', '" & stby & "', '" & stpost & "', '" & stcpr & "', '" & stmobiltelefon & "', '" & stemail & "') ;"
connect.execute(sqlAddUser)
validateForm = "validated"
end if
end if
%>
<HTML>
<HEAD>
<TITLE>Bruger oprettelse</TITLE>
<STYLE>
body {
font-family: verdana;
}
</STYLE>
</HEAD>
<BODY bgcolor="#000000" link="#808080" vlink="#808080" alink="#808080">
<CENTER>
<DIV CLASS="header"><b><u><font color="#FFFFFF" size="5">Info-mailkartotek</font></u></b></DIV>
<FORM NAME="frmUsers" METHOD="post">
<INPUT TYPE="hidden" NAME="mode" VALUE="addUser">
<TABLE BORDER="0">
<tr>
<TD>
<b><font color="#FFFFFF">Fulde Navn:</font></b></TD>
<TD <% if username = "error" then response.write "BGCOLOR=""red""" end if %> bgcolor="#808080" >
<font color="#FFFFFF">
<INPUT TYPE="text" NAME="username" size="21"></font></TD>
</tr>
<tr>
<TD>
<b><font color="#FFFFFF">Postnummer:</font></b></TD>
<TD <% if by = "error" then response.write "BGCOLOR=""red""" end if %> bgcolor="#808080" >
<font color="#FFFFFF">
<INPUT TYPE="text" NAME="post" size="21"></font></TD>
</tr>
<tr>
<TD>
<b><font color="#FFFFFF">By:</font></b></TD>
<TD <% if by = "error" then response.write "BGCOLOR=""red""" end if %> bgcolor="#808080" >
<font color="#FFFFFF">
<INPUT TYPE="text" NAME="by" size="21"></font></TD>
</tr>
<tr>
<TD>
<b><font color="#FFFFFF">Fødsels dato: ddmmaa </font></b></TD>
<TD <% if by = "error" then response.write "BGCOLOR=""red""" end if %> bgcolor="#808080" >
<font color="#FFFFFF">
<INPUT TYPE="text" NAME="cpr" size="21"></font></TD>
</tr>
<tr>
<TD>
<b><font color="#FFFFFF">Mobiltelefon:</font></b></TD>
<TD <% if telefon = "error" then response.write "BGCOLOR=""red""" end if %> bgcolor="#808080" >
<font color="#FFFFFF">
<INPUT TYPE="text" NAME="mobiltelefon" size="21"></font></TD>
</tr>
<tr>
<TD>
<b>
<font color="#FFFFFF">
E-mail:</font></b></TD>
<TD <% if email = "error" then response.write "BGCOLOR=""red""" end if %> bgcolor="#808080" >
<font color="#FFFFFF">
<INPUT TYPE="text" NAME="email" <% if email <> "error" then response.write "VALUE=""" & stemail & """"%> size="21"></font></TD>
</tr>
<TR>
<TD COLSPAN="2" ALIGN="right">
<font color="#FFFFFF">
<INPUT CLASS="botton" TYPE="reset" VALUE="Slet"> <INPUT CLASS="botton" TYPE="submit" VALUE="Opret"></font></TD>
</TR>
</TABLE>
</FORM>
<%
if validateForm = "invalid" then
response.write "<FONT COLOR=""red""><B>"
If userName = "error" then
response.write "Brugernavnet skal værer mellem 3 og 20 bogstaver. <BR>"
end if
If by = "error" then
response.write "By navn må maks være på 20 ciffer. <BR>"
end if
If post = "error" then
response.write "Post nummer må maks være 4 ciffer. <BR>"
end if
If cpr = "error" then
response.write "Der fejl i din fødsels dato den skal kun være de 6 første ciffre. Og det skal skrive således 121278 = 12 december 1978<BR>"
end if
If mobiltelefon = "error" then
response.write "Mobiltelefon nummeret kan kun være 8 ciffer. <BR>"
end if
If email = "error" then
response.write "E-mail adresse kun være på 20 ciffer. <BR>"
elseif nameCheck = "error" then
response.write "E-mail adressen er registret i forvejen - enten har du lavet en fejl eller så eksistere du i forvejen <BR>"
end if
response.write "</B></FONT>"
end if
%>
</CENTER>
<%
connect.close
set connect = nothing
%>
</BODY>
</HTML>
--------------
Nogen er kan se fejlen ??