Skyldes det access eller noget andet?
Jeg vil lave en side hvor man kan tilmelde sig en service... Derfor har jeg en side med en form:<table>
<tr>
<td align="center"><img src="images/titlebar_bs.gif" width="778" height="46"></td>
</tr>
<tr>
<td align="center">
<br>
<div align="right">
<table border="0" width="580" cellspacing="0" cellpadding="0">
<tr>
<td width="387">
<table border="0" width="386" cellspacing="0" cellpadding="0">
<tr>
<td height="29" width="387"> <img border="0" src="images/menubar.gif" width="387" height="29"></td>
</tr>
<tr>
<td bgcolor="#EFEFEF" width="386"><font face="Arial" size="2"><b>Opret en bruger</b></font>
<br>
<font face="Arial" size="2">
Udfyld disse felter og tryk på videre...</font><br>
<form method="POST" action="opretto.asp" onsubmit="validering();return false;">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="24%"><b><font size="2" face="Arial">Fornavn</td>
<td width="76%"> <input type="text" name="fornavn" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">Efternavn</td>
<td width="76%"> <input type="text" name="efternavn" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">Brugernavn</td>
<td width="76%"> <input type="text" name="brugernavn" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">Adgangskode</td>
<td width="76%"> <input type="password" name="kodeord" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">Adresse</td>
<td width="76%"> <input type="text" name="adresse" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">By</td>
<td width="76%"> <input type="text" name="city" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">Postnummer</td>
<td width="76%"> <input type="text" name="postnummer" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">E-mail </td>
<td width="76%"> <input type="text" name="email" size="20"></td>
</tr>
</table>
<br><br>
<font face="Arial" size="2"><b>Opret din annonce</b></font>
<br>
<font face="Arial" size="2">Du skal også lige oprette din annonce...</font><br>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="24%"><b><font size="2" face="Arial">Adresse for bolig</font></b></td>
<td width="76%"> <input type="text" name="boligaddresse" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">By for bolig</td>
<td width="76%"> <input type="text" name="boligcity" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">Postnummer for bolig</td>
<td width="76%"> <input type="text" name="boligpostnummer" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">Pris for bolig pr. mdr.</td>
<td width="76%"> <input type="text" name="pris" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">Antal kvm.</td>
<td width="76%"> <input type="text" name="kvm" size="20"></td>
</tr>
<tr>
<td width="24%"><b><font size="2" face="Arial">Amt for bolig</td>
<td width="76%"> <select name="amt">
<option value="Bornholm" >Bornholm</option>
<option value="Frederiksborg" >Frederiksborg</option>
<option value="Fyn" >Fyn</option>
<option value="København" >København</option>
<option value="Nordjylland" >Nordjylland</option>
<option value="Ribe" >Ribe</option>
<option value="Ringkjøbing" >Ringkjøbing</option>
<option value="Roskilde" >Roskilde</option>
<option value="Storstrøm" >Storstrøm</option>
<option value="Sønderjylland" >Sønderjylland</option>
<option value="Vestsjælland" >Vestsjælland</option>
<option value="Vejle" >Vejle</option>
<option value="Viborg" >Viborg</option>
<option value="Århus" >Århus</option>
</select> </td>
</tr>
</table>
<center>
<p><input type="submit" value="Opret" name="et"><br></p>
</td>
</tr>
</table>
</td>
<td width="12"></td>
<td width="180" valign="top" align="left"> <font face="Arial" size="1"><b> </b></font><br>
<font face="Arial" size="1">
</font>
</td>
</tr>
</table>
</div>
<!--#Include file="include/bund.asp" -->
---------------------------------------------
Og en side der skal skrive til en access db...:
<%
' Databaseforbindelse - husk at angive sti til din database
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSN = DSN & "DBQ=" & Server.MapPath("fpdb/bolig.mdb")
Conn.Open DSN
' SQL sætning opbygges
strSQL = "Insert into bruger ("
strSQL = strSQL & "fornavn, "
strSQL = strSQL & "efternavn, "
strSQL = strSQL & "kodeord, "
strSQL = strSQL & "brugernavn, "
strSQL = strSQL & "adresse, "
strSQL = strSQL & "city, "
strSQL = strSQL & "postnummer, "
strSQL = strSQL & "email) "
strSQL = strSQL & "values( "
strSQL = strSQL & "'" & Request.Form("fornavn") & "', "
strSQL = strSQL & "'" & Request.Form("efternavn") & "', "
strSQL = strSQL & "'" & Request.Form("kodeord") & "', "
strSQL = strSQL & "'" & Request.Form("brugernavn") & "', "
strSQL = strSQL & "'" & Request.Form("adresse") & "', "
strSQL = strSQL & "'" & Request.Form("city") & "', "
strSQL = strSQL & "'" & Request.Form("postnummer") & "', "
strSQL = strSQL & "'" & Request.Form("email") & "')"
strSQL = "Insert into boliger ("
strSQL = strSQL & "boligaddresse, "
strSQL = strSQL & "boligcity, "
strSQL = strSQL & "boligpostnummer, "
strSQL = strSQL & "pris, "
strSQL = strSQL & "amt, "
strSQL = strSQL & "kvm) "
strSQL = strSQL & "values( "
strSQL = strSQL & "'" & Request.Form("boligaddresse") & "', "
strSQL = strSQL & "'" & Request.Form("boligcity") & "', "
strSQL = strSQL & "'" & Request.Form("boligpostnummer") & "', "
strSQL = strSQL & "'" & Request.Form("pris") & "', "
strSQL = strSQL & "'" & Request.Form("amt") & "', "
strSQL = strSQL & "'" & Request.Form("kvm") & "')"
' SQL sætning eksekveres
Conn.Execute(strSQL)
' Luk databaseforbindelse
Conn.Close
Set Conn = Nothing
%>
----------------------------------------
Men jeg får bare denne fejl:
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.
/ve/bolig/opretto.asp, line 52
------------------------
Siden kan ses her:
http://students.aabc.dk/ve/bolig/opret.asp
og db'en kan ses her:
http://students.aabc.dk/ve/bolig/bolig.mdb
Nogle der ved hvad fejlen er?
(jeg har nemlig ikke access på denne computer og kan derfor ikke se om der er noget i vejen med db'en)