Telefonnummer med 2 x 4 tal på en anden måde
Dette virker fint i én sammenhæng:<% Response.Write Mid(rs("telefon"),1,4) & " " & Mid(rs("telefon"),5,4) %>
Men hvad gør jeg i dette tilfælde:
rsAddComments.Fields("navn1") = Request.Form("navn1")
rsAddComments.Fields("navn2") = Request.Form("navn2")
rsAddComments.Fields("tlf") = Request.Form("tlf")
'I linjen herover skal det Mid-funktionen sættes ind, men hvordan
rsAddComments.Fields("email") = Request.Form("email")
rsAddComments.Fields("web2") = Request.Form("web2")
Hele filens indhold er her:
<%
Response.Buffer = True %>
<%'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added to the database
Dim strSQL 'Holds the SQL query for the database
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("afbux.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"
'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT afbud.dato, afbud.navn1, afbud.navn2, afbud.tlf, afbud.email, afbud.web2 FROM afbud ORDER by dato;"
'Set the cursor type we are using so we can navigate through the recordset
rsAddComments.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsAddComments.LockType = 3
'Open the afbux table using the SQL query held in the strSQL varaiable
rsAddComments.Open strSQL, adoCon
'Tell the recordset we are adding a new record to it
rsAddComments.AddNew
'Add a new record to the recordset
if Request.Form("dato") = "" then
Session("tekst") = "Indtastning af dato er obligatorisk!!"
Response.Redirect "guestbook_form.asp"
else
rsAddComments.Fields("dato") = Request.Form("dato")
end if
rsAddComments.Fields("navn1") = Request.Form("navn1")
rsAddComments.Fields("navn2") = Request.Form("navn2")
rsAddComments.Fields("tlf") = Request.Form("tlf")
rsAddComments.Fields("email") = Request.Form("email")
rsAddComments.Fields("web2") = Request.Form("web2")
'Write the updated recordset to the database
rsAddComments.Update
'Reset server objects
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
'Redirect to the guestbook.asp page
Response.Redirect "guestbook.asp"
%>
