Selve eksemplet ligger her:
http://www.nythjem.dk/test2/Der er nogle filer du skal oprette:
#### udfyld.asp ####
<html>
<head>
<title>eksempel</title>
</head>
<body>
<form action="indsaet.asp" method="post">
Firma: <input type="text" name="firma" size="15" value=""><br>
Telefon: <input type="text" name="telefon" size="15" value=""><br><br>
<input type="checkbox" name="vip" value="ON"> Vip?<br>
<input type="checkbox" name="erhverv" value="ON"> Erhverv?
<br>
<br>
<br>
<input type="submit" value="Gem"></form>
</body>
</html>
#### indsaet.asp ####
<%
' 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("TEST.mdb")
Conn.Open DSN
' SQL sætning opbygges
strSQL = "Insert into oplysning ("
strSQL = strSQL & "Firma, "
strSQL = strSQL & "Vip, "
strSQL = strSQL & "Erhverv, "
strSQL = strSQL & "Telefon) "
strSQL = strSQL & "values( "
strSQL = strSQL & "'" & replace(request.form("Firma"),"'","´") & "', "
if request.form("vip") = "ON" then
strSQL = strSQL & "True, "
else
strSQL = strSQL & "False, "
end if
if request.form("erhverv") = "ON" then
strSQL = strSQL & "True, "
else
strSQL = strSQL & "False, "
end if
strSQL = strSQL & "'" & replace(request.form("Telefon"),"'","´") & "')"
' SQL sætning eksekveres
Conn.Execute(strSQL)
' Luk databaseforbindelse
Conn.Close
Set Conn = Nothing
response.redirect ("rediger.asp")
%>
#### rediger.asp ####
<html>
<head>
<title>eksempel</title>
</head>
<body>
<%
Response.Buffer = True
Set Con = Server.CreateObject("ADODB.Connection")
DBPath = "DBQ=" & server.mappath("TEST.mdb")
Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & DBPath
Sql = "SELECT * FROM OPLYSNING"
Set Record = Con.Execute(Sql)
%>
<% Do while Not Record.EOF %>
<form action="gem-aendring.asp?id=<%=Record("id")%>" method="post">
Firma: <input type="text" name="firma" size="15" value="<%=Record("firma")%>"><br>
Telefon: <input type="text" name="telefon" size="15" value="<%=Record("telefon")%>"><br><br>
<input type="checkbox" name="vip" <% If Record("vip") = True Then %>checked<%Else%><%End If%> value="ON"> Vip?<br>
<input type="checkbox" name="erhverv" <% If Record("erhverv") = True Then %>checked<%Else%><%End If%> value="ON"> Erhverv?
<br>
<br>
<input type="submit" value="Gem ændring"></form>
<%
Record.MoveNext
Loop
%>
<%
Con.Close
Set Con = Nothing
%>
</body>
</html>
#### gem-aendring ####
<%
' #### Databaseforbindelse ####
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSN = DSN & "DBQ=" & Server.MapPath("TEST.mdb")
Conn.Open DSN
' #### SQL sætning opbygges ####
strSQL = "Update OPLYSNING set "
if request("vip") = "ON" then
strSQL = strSQL & "vip = True, "
else
strSQL = strSQL & "vip = False, "
end if
if request("erhverv") = "ON" then
strSQL = strSQL & "erhverv = True, "
else
strSQL = strSQL & "erhverv = False, "
end if
strSQL = strSQL & "Firma= '" & request.form("Firma") & "', "
strSQL = strSQL & "Telefon= '" & request.form("Telefon") & "' "
strSQL = strSQL & " Where ID = " & request.querystring("ID") & " "
' SQL sætning eksekveres
Conn.Execute(strSQL)
' Luk databaseforbindelse
Conn.Close
Set Conn = Nothing
response.redirect ("rediger.asp")
%>
*** databasen kan du downloade her..
http://www.nythjem.dk/test2/TEST.mdb;-)
Nåh, jeg vil tilbage til arbejdet :)