hjælp til connect.asp

Tags:    asp

jeg har været igang med at lave en gæste bog men jeg skulle ha lavet en connect.asp men kender ikke koderne der til please help me gæstebogs koderne er


<% OPTION EXEPLICIT %>
<!-- #include file="connect.asp" -->
<html><head><title>gæstebog</title></head>
<body>

<%
dim strAction
strAction=request("action")

select casestrAction
case "write"
' Vis formular til indtasting
ShowOptions
ShowForm
case "show"
' vis indhold
ShowOptions
ShowList request("fromid")
case "insert"
'indsæt resultat af formular
WriteFrom
ShowOptions
ShowList 0
case else
' vis valgmuligheder
ShowOptions
end select

'---------------------------------------------
'Funktioner og procedure
'---------------------------------------------

sub ShowForm
'viser en formular, hvor den besøgende skal indtaste i.
%>
<form action="guestbook.asp?action=insert" method="post">
Navn: <input type="text" name="guestname" size="20"><br>
E-Mail: <input type="text" name="guestmail" size="20"><br>
<textarea name="guestmassage" rows="1" cols="20"> </testarea<>br>
<input type="submit" value="Indsend">
</textarea><%
end sub

sub ShowList (intFromID)
'viser indlæg i gæstebogen.
' 10 indlæg vises ad gangen.
dim strSQL, objeRS, strWhere
dim arrRows, i
if intfromID > o then
StrWhere = " WHERE guestid <= " & intFromID & " "
else
strWhere = ""
end if

strSQL = "SELECT guestid, guestname, " & _
"guestmail,guestmessage FROM GuestBook " & _
strWhere & _
"ORDER BY datasubmitted DESC"

set objRS = server.createobject("ADODB.Recordset")
with objRS
.open strSQL, strConnect, adOpenForwardOnly, adLockReadOnly. adCmdText
if not .EOF then
arrRows = .GetRows(10)
end if
.close
end with
set objRS = nothing


if is Arry(arrRows) then
intFormID = arrRows(0,ubound(arrRows,2))
for i = 0 to ubound(arrRows,2)
response.write arrRows(0,i) & ". " & _
arrRows(1,i) & _'
"<br>" & arrRows(2,i) & _
"<br>" & arrRows(3,i) & "<hr>"
next
response.Write _
"<a href='guestbook.asp?action=show&fromid=" & intFromID+10 & "'>Tilbage</a> " & _
"<a href='guestbook.asp?action=show&fromid=" & intFromID - 1 & "'>Frem</a>"
else
response.write "<p>Ikke flere indlæg i gæstebogen.</p>"
end if
end sub


sub WriteForm
'Indlægget skrives til databasen.
dim strSQL, objCMD
strSQL = "INSERT INTO GuestBook " & _
"(guestname, guestmail, guestmessage, datesubmitted) " & _
"VALUES (" & _
"'" &request("guestname") & "', " & _
"'" &request("guestmail") & "', " & _
"'" &request("guestmassage") & "', " & _
"egtdate()" & _
")"

set objCMD = server.createobject("ADODB:Command")
with objCMD
.ActiveConnection = strConnect
.CommandType = adCmdText
.CommandText = strSQL
.Esecute
end with
set objCMD = Nothing
end sub
sub ShowOptions
' Viser, hvilker muligheder der er .
%>
<h1>Gæstebog</h1>
<p>Hej, du kan skrive i min gæstebog, hvist du har lyst.
<br>
<a href="guestbook.asp?action=write">Skriv i gæstebogen</a><br>
<a href="guestbook.asp?action=shoe">Se hvad andre har skrevet</a>
</p>
<%
end sub
%>
</body></html>



2 svar postet i denne tråd vises herunder
0 indlæg har modtaget i alt 0 karma
Sorter efter stemmer Sorter efter dato
jeg har været igang med at lave en gæste bog men jeg skulle ha lavet en connect.asp men kender ikke koderne der til please help me gæstebogs koderne er


<% OPTION EXEPLICIT %>
<!-- #include file="connect.asp" -->
<html><head><title>gæstebog</title></head>
<body>

<%
dim strAction
strAction=request("action")

select casestrAction
case "write"
' Vis formular til indtasting
ShowOptions
ShowForm
case "show"
' vis indhold
ShowOptions
ShowList request("fromid")
case "insert"
'indsæt resultat af formular
WriteFrom
ShowOptions
ShowList 0
case else
' vis valgmuligheder
ShowOptions
end select

'---------------------------------------------
'Funktioner og procedure
'---------------------------------------------

sub ShowForm
'viser en formular, hvor den besøgende skal indtaste i.
%>
<form action="guestbook.asp?action=insert" method="post">
Navn: <input type="text" name="guestname" size="20">
E-Mail: <input type="text" name="guestmail" size="20">
<textarea name="guestmassage" rows="1" cols="20"> </testarea<>br>
<input type="submit" value="Indsend">
</textarea><%
end sub

sub ShowList (intFromID)
'viser indlæg i gæstebogen.
' 10 indlæg vises ad gangen.
dim strSQL, objeRS, strWhere
dim arrRows, i
if intfromID > o then
StrWhere = " WHERE guestid <= " & intFromID & " "
else
strWhere = ""
end if

strSQL = "SELECT guestid, guestname, " & _
"guestmail,guestmessage FROM GuestBook " & _
strWhere & _
"ORDER BY datasubmitted DESC"

set objRS = server.createobject("ADODB.Recordset")
with objRS
.open strSQL, strConnect, adOpenForwardOnly, adLockReadOnly. adCmdText
if not .EOF then
arrRows = .GetRows(10)
end if
.close
end with
set objRS = nothing


if is Arry(arrRows) then
intFormID = arrRows(0,ubound(arrRows,2))
for i = 0 to ubound(arrRows,2)
response.write arrRows(0,i) & ". " & _
arrRows(1,i) & _'
"" & arrRows(2,i) & _
"" & arrRows(3,i) & "<hr>"
next
response.Write _
"<a href='guestbook.asp?action=show&fromid=" & intFromID+10 & "'>Tilbage</a> " & _
"<a href='guestbook.asp?action=show&fromid=" & intFromID - 1 & "'>Frem</a>"
else
response.write "<p>Ikke flere indlæg i gæstebogen.</p>"
end if
end sub


sub WriteForm
'Indlægget skrives til databasen.
dim strSQL, objCMD
strSQL = "INSERT INTO GuestBook " & _
"(guestname, guestmail, guestmessage, datesubmitted) " & _
"VALUES (" & _
"'" &request("guestname") & "', " & _
"'" &request("guestmail") & "', " & _
"'" &request("guestmassage") & "', " & _
"egtdate()" & _
")"

set objCMD = server.createobject("ADODB:Command")
with objCMD
.ActiveConnection = strConnect
.CommandType = adCmdText
.CommandText = strSQL
.Esecute
end with
set objCMD = Nothing
end sub
sub ShowOptions
' Viser, hvilker muligheder der er .
%>
<h1>Gæstebog</h1>
<p>Hej, du kan skrive i min gæstebog, hvist du har lyst.

<a href="guestbook.asp?action=write">Skriv i gæstebogen</a>
<a href="guestbook.asp?action=shoe">Se hvad andre har skrevet</a>
</p>
<%
end sub
%>
</body></html>





skod



t