18. januar 2004 - 19:24
Der er
28 kommentarer og 1 løsning
Korrigere asp kode
Jeg forsøger at udvide et news-system så man også kan indsætte billeder til nyhedstekst. Det er to filer: index.asp og opret.asp Jeg paster de to filer og håber på hjælp til korrigering :)
Annonceindlæg tema
Forsvar & beredskab
Cybersikkerhed, realtidsdata og robuste it-systemer er blevet fundamentet for moderne forsvar.
18. januar 2004 - 19:24
#1
filnavn: index.sp <% Session.LCID = 1030 %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <link rel="StyleSheet" href="CSS.css" type="text/css"> </head> <body> <br> <% intPage = Request("page") If isNumeric(intPage) = False Or intPage < 1 Then intPage = 1 End If strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("database.mdb") Set rstemp = Server.CreateObject("ADODB.RecordSet") strSQL = "SELECT * FROM News ORDER by id desc" rstemp.Open strSQL, strDSN, 1 If Not (rstemp.BOF Or rstemp.EOF) Then rstemp.PageSize = 4 rstemp.AbsolutePage = intPage intRecCount = rstemp.PageSize intPageCount = rstemp.PageCount %> <% Do While Not rstemp.EOF And intRecCount > 0 %> <center> <table border="0" width="610" cellspacing="2" cellpadding="2"> <tr> <td width="610"><h2><%=rstemp("overskrift").Value %></h2></td> </tr> <tr> <td width="610" valign="bottom"> <%if rstemp("mynd").Value <> "" then mynd= "<img border=0 src=" & rstemp("mynd").Value & " width=299 height=195>" else mynd="" end if %> <table border="0" cellpadding="3" cellspacing="3" width="100%"> <tr> <td width="300" valign="bottom"><%=mynd%> <!--<img border="0" src="citroen.jpg" width="299" height="195"> --> </td> <td width="300" valign="bottom"><%=rstemp("tekst").Value %></td> </tr> </table> </td> </tr> <tr> <td width="610" bgcolor="#F6F6F6"><%=rstemp("dato").Value %><b></b></td> </tr> </table> </center> <br> <% intRecCount = intRecCount - 1 rstemp.movenext loop else End If %> <div align="center"> <hr width="600"> <table border="0"> <tr> <td> <% If Clng(intPage) > 1 Then Response.Write "<a href=index.asp?page="& intPage - 1 &"><< Aftur</a>" Else Response.Write " " End If %> </td> <td> <% For intNum = 1 To intPageCount Response.Write "<a href=index.asp?page=" & intNum & ">" & intNum & "</a> - " Next %> </td> <td> <% If Clng(intPage) < Clng(intPageCount) Then Response.Write "<a href=index.asp?page="& intPage + 1 &">Næsta >></font></a> " Else Response.Write " " End If %> </td> </tr> </table><br><hr width="600"><br><br><br><br> </center> </div> <% rstemp.Close Set rstemp = Nothing %> </body> </html>
18. januar 2004 - 19:24
#2
Filnavn: opret.asp <% Session.LCID = 1030 %> <% Response.Buffer = True %> <html> <head> <link rel="StyleSheet" href="CSS.css" type="text/css"> </head> <body><br> <% if Session("Brugeradgang") <> True then %> <form method="POST" action="opret.asp?mode=login"> <div align="center"> <center> <table border="0" width="172" cellspacing="0" cellpadding="2" height="1"> <tr> <td width="166" bgcolor="#BECACD" style="border: 1 solid #000000" height="15"><font face="verdana" size="1"><b>Admin login</b> - </font></td> </tr> </center> <tr> <td width="166" bgcolor="#DCE2E4" style="border-left: 1 solid #000000; border-right: 1 solid #000000; border-bottom: 1 solid #000000" height="1"> <p align="left"><font face="verdana" size="1"> Brugernavn<br><input type="text" name="brugernavn" size="20"><br> Adgangskode<br><input type="password" name="adgangskode" size="20"><br> <input type="submit" value="Login" name="B1" style="background-color: #occoco"> </p> </font> </td> </tr> </table> </div> </form> <% else %> <% Set Conn = Server.CreateObject("ADODB.Connection") DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; " DSN = DSN & "DBQ=" & Server.MapPath("database.mdb") Conn.Open DSN strMode = Request.Querystring("mode") if strMode = "opret" then if Session("Brugeradgang") = True then %> <form method="POST" action="opret.asp?mode=oprettet"> <div align="center"> <center> <table border="0" width="500" cellspacing="0" cellpadding="2"> <tr> <td width="100%" style="border: 1 solid #000000" bgcolor="#BECACD"><b>Opret nyhed</b></td> </tr> <tr> <td width="100%" style="border-left: 1 solid #000000; border-right: 1 solid #000000; border-bottom: 1 solid #000000"> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr> <td width="16%"><b>Overskrift</b></td> <td width="50%"><font face="verdana" size="1"> <input type="text" name="overskrift" size="62" style="font-size: 8pt; font-family: Verdana; border: 1 solid #000000"> </font> </td> </tr> <tr> <td width="16%"><font face="verdana" size="1"><b>Billede</b></font></td> <td width="50%"><font face="verdana" size="1"> <% mvirtual = "/asp/myndir/" 'her billeder set fso = Server.CreateObject("Scripting.FileSystemObject") set mappa = fso.GetFolder(Server.MapPath(mvirtual)) set filur = mappa.files tmp = "<SELECT SIZE=4 NAME=""mynd"" CLASS=""field"">" & VbCrLf tmp = tmp & "<OPTION SELECTED VALUE=""" & "Eingin mynd" & """" tmp = tmp & ">-- Eingin mynd --</OPTION>" & VbCrLf for each file in filur tmp = tmp & "<OPTION VALUE=""" & file.name & """" tmp = tmp & ">" & file.name & "</OPTION>" & VbCrLf Next tmp = tmp & "</SELECT>" set filur = nothing set mappa = nothing set fso = nothing Response.Write(tmp) %> </td> </tr> <tr> <td width="16%"><b>Tekst</b></td> <td width="50%"><textarea rows="16" name="tekst" cols="61"></textarea></td> </tr> <tr> <td width="16%"></td> <td width="50%"><font face="verdana" size="1"> <input type="submit" value="Opret nyhed" name="B1" style="background-color: #DCE2E4"> </font> </td> </tr> </table> </td> </tr> </table> </center> </div> </form> <br> <% end if elseif strMode = "oprettet" then if Session("Brugeradgang") = True then Set Conn = Server.CreateObject("ADODB.Connection") DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; " DSN = DSN & "DBQ=" & Server.MapPath("database.mdb") Conn.Open DSN strSQL = "Insert into news (dato, overskrift, tekst, mynd) values (" & DatePart("D",Now()) & "-" & DatePart("M",Now()) & "-" & DatePart("YYYY",Now()) & "," & Request.Form("overskrift") & "," & Request.Form("tekst") & ", " & Request.Form("mynd") & ")" Conn.Execute(strSQL) Conn.Close Set Conn = Nothing Response.Redirect "opret.asp" end if elseif strMode = "ret" then if Session("Brugeradgang") = True then Set Conn = Server.CreateObject("ADODB.Connection") DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; " DSN = DSN & "DBQ=" & Server.MapPath("database.mdb") Conn.Open DSN strQuery = "SELECT * FROM news WHERE id = " & Request.Querystring("news_id") & "" Set rs = Conn.Execute(strQuery) %> <form method="POST" action="?mode=rettet&news_id=<% Response.Write Request.Querystring("news_id") %>"> <div align="center"> <center> <table border="0" width="500" cellspacing="0" cellpadding="2"> <tr> <td width="100%" style="border: 1 solid #000000" bgcolor="#BECACD"><font face="verdana" size="1"><b>Redigere:</b> <%=rs("overskrift").Value %></font></td> </tr> <tr> <td width="100%" style="border-left: 1 solid #000000; border-right: 1 solid #000000; border-bottom: 1 solid #000000" bgcolor="#DCE2E4"> <table border="0" width="100%" cellpadding="0"> <tr> <td width="16%"><font face="verdana" size="1"><b>Overskrift</b></font></td> <td width="84%"><font face="verdana" size="1"> <input type="text" name="overskrift" size="62" style="font-size: 8pt; font-family: Verdana; border: 1 solid #000000" value="<%=rs("overskrift").Value %>"> </font> </td> </tr> <tr> <td width="16%"><font face="verdana" size="1"><b>Tekst</b></font></td> <td width="84%"><textarea rows="16" name="tekst" cols="61" style="font-size: 8pt; font-family: Verdana; border: 1 solid #000000"><%=rs("tekst").Value %></textarea></td> </tr> <tr> <td width="16%"><font face="verdana" size="1"> </font></td> <td width="84%"><font face="verdana" size="1"> <input type="submit" value=" Ret " name="B1" style="background-color: #DCE2E4; font-size: 8pt; font-family: Verdana"> </font> </td> </tr> </table> </td> </tr> </table> </center> </div> </form> <br> <% rs.Close Conn.Close Set Conn = Nothing Set rs = Nothing end if elseif strMode = "rettet" then if Session("Brugeradgang") = True then Set Conn = Server.CreateObject("ADODB.Connection") DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; " DSN = DSN & "DBQ=" & Server.MapPath("database.mdb") Conn.Open DSN strSQL = "Update news set overskrift= '" & Request.Form("overskrift") & "' , tekst= '" & Request.Form("tekst") & "' Where id = " & Request.Querystring("news_id") & "" Conn.Execute(strSQL) Response.Redirect "?" rs.Close Conn.Close Set Conn = Nothing Set rs = Nothing end if elseif strMode = "slet" then if Session("Brugeradgang") = True then Set Conn = Server.CreateObject("ADODB.Connection") DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; " DSN = DSN & "DBQ=" & Server.MapPath("database.mdb") Conn.Open DSN strSQL = "Delete from news where id = " & Request.Querystring("news_id") & "" Conn.Execute(strSQL) Response.Redirect "?" rs.Close Conn.Close Set Conn = Nothing Set rs = Nothing end if else if Session("Brugeradgang") = True then Set Conn = Server.CreateObject("ADODB.Connection") DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; " DSN = DSN & "DBQ=" & Server.MapPath("database.mdb") Conn.Open DSN strQuery = "SELECT * FROM news Order By id Desc" Set rs = Conn.Execute(strQuery) %> <div align="center"> <center> <table border="0" width="500" cellspacing="0" cellpadding="4" style="border: 1 solid #000000"> <tr> <td width="15%" bgcolor="#BECACD"><font face="verdana" size="1"><b>Dato</b></font></td> <td width="45%" bgcolor="#BECACD"><font face="verdana" size="1"><b>Overskrift</b></font></td> <td width="30%" bgcolor="#BECACD"><font face="verdana" size="1"><b>Skrevet af</b></font></td> <td width="5%" bgcolor="#BECACD"><font face="verdana" size="1"> </font></td> <td width="5%" bgcolor="#BECACD"><font face="verdana" size="1"> </font></td> </tr> <% Do While Not rs.EOF %> <tr> <td width="15%" style="border-top: 1 solid #000000" bgcolor="#DCE2E4"><font face="verdana" size="1"><%=rs("dato").Value %></font></td> <td width="45%" style="border-top: 1 solid #000000" bgcolor="#DCE2E4"><font face="verdana" size="1"><%=rs("overskrift").Value %></font></td> <td width="30%" style="border-top: 1 solid #000000" bgcolor="#DCE2E4"><font face="verdana" size="1"><%=rs("forfatter").Value %></font></td> <td width="5%" style="border-top: 1 solid #000000" bgcolor="#DCE2E4"><font face="verdana" size="1"><b><a href="?mode=ret&news_id=<%=rs("id").Value %>">Ret</a></b></font></td> <td width="5%" style="border-top: 1 solid #000000" bgcolor="#DCE2E4"><font face="verdana" size="1"><b><a href="?mode=slet&news_id=<%=rs("id").Value %>">Slet</a></b></font></td> </tr> <% rs.MoveNext Loop %> </table> </center> </div> <% end if rs.Close Conn.Close Set Conn = Nothing Set rs = Nothing end if end if %> <% strMode = Request.Querystring("mode") if strMode = "login" then Set Conn = Server.CreateObject("ADODB.Connection") DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; " DSN = DSN & "DBQ=" & Server.MapPath("database.mdb") Conn.Open DSN strBrugernavn = Trim(Replace(request.form("brugernavn"),"'","''" )) strAdgangskode = Trim(Replace(request.form("adgangskode"),"'","''" )) SQL = "SELECT * FROM admin where brugernavn = '" & strBrugernavn & "' AND adgangskode = '" & strAdgangskode & "'" Set rs = Conn.Execute(SQL) If Not (rs.BOF Or rs.EOF) Then Session("id") = rs("id").Value Session("forfatter") = rs("forfatter").Value Session("email") = rs("email").Value Session("Brugeradgang") = True Response.Redirect "?" else %> <p align="center"><font face="verdana" size="1">Du er ikke logget på.<br>Har du indtastet brugernavn og adgangskode forkert? </font></p> <% end if end if %> <% strMode = Request.Querystring("mode") if strMode = "logud" then Session.Abandon Response.Redirect "?" end if %> <p align="center"><font face="verdana" size="1"><a href="opret.asp?mode=opret">Opret nyhed</a> - <a href="opret.asp?mode=logud">Log ud</a> - <a href="#" OnClick="java script:history.go(-1)">Back</a></font></p> </body> </html>
18. januar 2004 - 19:29
#3
<% Session.LCID = 1030 %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <link rel="StyleSheet" href="CSS.css" type="text/css"> </head> <body> <br> <% intPage = Request("page") If isNumeric(intPage) = False Or intPage < 1 Then intPage = 1 End If strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("database.mdb") Set rstemp = Server.CreateObject("ADODB.RecordSet") strSQL = "SELECT * FROM News ORDER by id desc" rstemp.Open strSQL, strDSN, 1 If Not (rstemp.BOF Or rstemp.EOF) Then rstemp.PageSize = 4 rstemp.AbsolutePage = intPage intRecCount = rstemp.PageSize intPageCount = rstemp.PageCount %> <% Do While Not rstemp.EOF And intRecCount > 0 %> <center> <table border="0" width="610" cellspacing="2" cellpadding="2"> <tr> <td width="610"><h2><%=rstemp("overskrift").Value %></h2></td> </tr> <tr> <td width="610" valign="bottom"> <%if rstemp("mynd").Value <> "" then mynd= "<img border=0 src=" & rstemp("mynd").Value & " width=299 height=195>" else mynd="" end if %> <table border="0" cellpadding="3" cellspacing="3" width="100%"> <tr> <td width="300" valign="bottom"><%=mynd%> <!--<img border="0" src="citroen.jpg" width="299" height="195"> --> </td> <td width="300" valign="bottom"><%=rstemp("tekst").Value %></td> </tr> </table> </td> </tr> <tr> <td width="610" bgcolor="#F6F6F6"><%=rstemp("dato").Value %><b></b><br><img src="/asp/myndir/<%=rs.fields("mynd")%>"></td> </tr> </table> </center> <br> <% intRecCount = intRecCount - 1 rstemp.movenext loop else End If %> <div align="center"> <hr width="600"> <table border="0"> <tr> <td> <% If Clng(intPage) > 1 Then Response.Write "<a href=index.asp?page="& intPage - 1 &"><< Aftur</a>" Else Response.Write " " End If %> </td> <td> <% For intNum = 1 To intPageCount Response.Write "<a href=index.asp?page=" & intNum & ">" & intNum & "</a> - " Next %> </td> <td> <% If Clng(intPage) < Clng(intPageCount) Then Response.Write "<a href=index.asp?page="& intPage + 1 &">Næsta >></font></a> " Else Response.Write " " End If %> </td> </tr> </table><br><hr width="600"><br><br><br><br> </center> </div> <% rstemp.Close Set rstemp = Nothing %> </body> </html> Hvis dine billeder ligger på serveren i forvejen, vil jeg tro det kan gøres ved blot at rette: index.asp til ovenstående...
18. januar 2004 - 19:43
#4
tak ellebaek får denne fejl: Microsoft VBScript runtime error '800a01a8' Object required: '' /asp/index.asp, line 60
18. januar 2004 - 19:43
#5
Linje 60 <td width="610" bgcolor="#F6F6F6"><%=rstemp("dato").Value %><b></b><br><img src="asp/myndir<%=rs.fields("mynd")%>"></td>
18. januar 2004 - 19:49
#6
Når jeg nu opretter en ny nyhed får jeg: Microsoft OLE DB Provider for ODBC Drivers error '80040e10' [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 3. /asp/opret.asp, line 123
18. januar 2004 - 19:50
#7
line 123: Conn.Execute(strSQL)
18. januar 2004 - 20:09
#8
c
18. januar 2004 - 21:06
#9
Undskyld jeg ikke har svaret før.. rs.fields til: rstemp("mynd") Hvor får du den anden fejl ?
18. januar 2004 - 21:25
#10
index.asp gir nu: Microsoft VBScript runtime error '800a01a8' Object required: '' /asp/index.asp, line 60
18. januar 2004 - 21:27
#11
Når man oretter ffår man: Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Eingin mynd'. /asp/opret.asp, line 123
18. januar 2004 - 21:29
#12
Opret.asp Når man også vælger billede: Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Blomstur-2.jpg'. /asp/opret.asp, line 123
18. januar 2004 - 21:43
#13
ellebaek > Takker - nu får jeg ikke fejl i index.asp
18. januar 2004 - 21:45
#14
ok... får du vist billederne ?
18. januar 2004 - 21:46
#15
Jeg har korrigeret: rs.fields til: rstemp("mynd") ---------------- Derfor er index.asp nu OK
18. januar 2004 - 21:50
#16
Kun et enkelt billede ses. Det er billedet, som jeg tastet manuelt i databasen inden jeg begyndete at lave om på koden :)
18. januar 2004 - 21:53
#17
Som det er nu er det ikke muligt at vælge billede nær man vælger "Ret" "Slet" fungerer 100% :)
18. januar 2004 - 22:01
#18
<table border="0" cellpadding="3" cellspacing="3" width="100%"> <tr> <td width="300" valign="bottom"><%=mynd%> <!--<img border="0" src="citroen.jpg" width="299" height="195"> --> </td> <td width="300" valign="bottom"><%=rstemp("tekst").Value %></td> </tr> </table> </td> </tr> <tr> <td width="610" bgcolor="#F6F6F6"><%=rstemp("dato").Value %><b></b><br><img src="asp/myndir<%=rstemp("mynd")%>"></td> </tr> </table>
18. januar 2004 - 22:03
#19
Kan man lave den foroven om til: <table border="0" cellpadding="3" cellspacing="3" width="100%"> <tr> <td width="300" valign="bottom"><%=mynd%> <img src="asp/myndir<%=rstemp("mynd")%>"> </td> <td width="300" valign="bottom"><%=rstemp("tekst").Value %></td> </tr> </table> </td> </tr> <tr> <td width="610" bgcolor="#F6F6F6"><%=rstemp("dato").Value %><b></b><br></td> </tr> </table>
18. januar 2004 - 22:54
#20
Nu har jeg tastet billeder i databasen og lavet om på koden så index.asp er OK med: <% Session.LCID = 1030 %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <link rel="StyleSheet" href="CSS.css" type="text/css"> </head> <body> <br> <% intPage = Request("page") If isNumeric(intPage) = False Or intPage < 1 Then intPage = 1 End If strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("database.mdb") Set rstemp = Server.CreateObject("ADODB.RecordSet") strSQL = "SELECT * FROM News ORDER by id desc" rstemp.Open strSQL, strDSN, 1 If Not (rstemp.BOF Or rstemp.EOF) Then rstemp.PageSize = 4 rstemp.AbsolutePage = intPage intRecCount = rstemp.PageSize intPageCount = rstemp.PageCount %> <% Do While Not rstemp.EOF And intRecCount > 0 %> <center> <table border="0" width="610" cellspacing="2" cellpadding="2"> <tr> <td width="610"><h2><%=rstemp("overskrift").Value %></h2></td> </tr> <tr> <td width="610" valign="bottom"> <%if rstemp("mynd").Value <> "" then mynd= "<img border=0 src=" & rstemp("mynd").Value & " width=299 height=195>" else mynd="" end if %> <table border="0" cellpadding="3" cellspacing="3" width="100%"> <tr> <td width="300" valign="bottom"> <img src="/asp/myndir/<%=rstemp("mynd")%>"> </td> <td width="300" valign="bottom"><%=rstemp("tekst").Value %></td> </tr> </table> </td> </tr> <tr> <td width="610" bgcolor="#F6F6F6"><%=rstemp("dato").Value %><b></b><br></td> </tr> </table> </center> <br> <% intRecCount = intRecCount - 1 rstemp.movenext loop else End If %> <div align="center"> <hr width="600"> <table border="0"> <tr> <td> <% If Clng(intPage) > 1 Then Response.Write "<a href=index.asp?page="& intPage - 1 &"><< Aftur</a>" Else Response.Write " " End If %> </td> <td> <% For intNum = 1 To intPageCount Response.Write "<a href=index.asp?page=" & intNum & ">" & intNum & "</a> - " Next %> </td> <td> <% If Clng(intPage) < Clng(intPageCount) Then Response.Write "<a href=index.asp?page="& intPage + 1 &">Næsta >></font></a> " Else Response.Write " " End If %> </td> </tr> </table><br><hr width="600"><br><br><br><br> </center> </div> <% rstemp.Close Set rstemp = Nothing %> </body> </html>
18. januar 2004 - 22:55
#21
ok... Så var problemet at man ikke kunne rette i billederne ?
18. januar 2004 - 22:58
#22
Så er det opret.asp - Når jeg skal oprette får jeg nu: Microsoft OLE DB Provider for ODBC Drivers error '80040e10' [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. /asp/opret.asp, line 123
18. januar 2004 - 23:00
#23
hvad er 123 ?
18. januar 2004 - 23:02
#24
Conn.Execute(strSQL)
18. januar 2004 - 23:05
#25
hvordan ser sql en ud ?
18. januar 2004 - 23:17
#26
opret.asp har bl.a.: <% Set Conn = Server.CreateObject("ADODB.Connection") DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; " DSN = DSN & "DBQ=" & Server.MapPath("database.mdb") Conn.Open DSN strMode = Request.Querystring("mode") if strMode = "opret" then if Session("Brugeradgang") = True then %> <form method="POST" action="opret.asp?mode=oprettet"> <div align="center"> <center> <table border="0" width="500" cellspacing="0" cellpadding="2"> <tr> <td width="100%" style="border: 1 solid #000000" bgcolor="#BECACD"><b>Opret nyhed</b></td> </tr> <tr> <td width="100%" style="border-left: 1 solid #000000; border-right: 1 solid #000000; border-bottom: 1 solid #000000"> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr> <td width="16%"><b>Overskrift</b></td> <td width="50%"><font face="verdana" size="1"> <input type="text" name="overskrift" size="62" style="font-size: 8pt; font-family: Verdana; border: 1 solid #000000"> </font> </td> </tr> <tr> <td width="16%"><font face="verdana" size="1"><b>Billede</b></font></td> <td width="50%"><font face="verdana" size="1"> <% mvirtual = "/asp/myndir/" 'her billeder set fso = Server.CreateObject("Scripting.FileSystemObject") set mappa = fso.GetFolder(Server.MapPath(mvirtual)) set filur = mappa.files tmp = "<SELECT SIZE=4 NAME=""mynd"" CLASS=""field"">" & VbCrLf tmp = tmp & "<OPTION SELECTED VALUE=""" & "Eingin mynd" & """" tmp = tmp & ">-- Eingin mynd --</OPTION>" & VbCrLf for each file in filur tmp = tmp & "<OPTION VALUE=""" & file.name & """" tmp = tmp & ">" & file.name & "</OPTION>" & VbCrLf Next tmp = tmp & "</SELECT>" set filur = nothing set mappa = nothing set fso = nothing Response.Write(tmp) %> </td> </tr> <tr> <td width="16%"><b>Tekst</b></td> <td width="50%"><textarea rows="16" name="tekst" cols="61"></textarea></td> </tr> <tr> <td width="16%"></td> <td width="50%"><font face="verdana" size="1"> <input type="submit" value="Opret nyhed" name="B1" style="background-color: #DCE2E4"> </font> </td> </tr> </table> </td> </tr> </table> </center> </div> </form> <br> <% end if elseif strMode = "oprettet" then if Session("Brugeradgang") = True then Set Conn = Server.CreateObject("ADODB.Connection") DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; " DSN = DSN & "DBQ=" & Server.MapPath("database.mdb") Conn.Open DSN strSQL = "Insert into news (dato, overskrift, tekst, mynd) values (" & DatePart("D",Now()) & "-" & DatePart("M",Now()) & "-" & DatePart("YYYY",Now()) & "," & Request.Form("overskrift") & "," & Request.Form("tekst") & ", " & Request.Form("mynd") & ")" Conn.Execute(strSQL)
18. januar 2004 - 23:49
#28
jeg får fejl i login...
19. januar 2004 - 00:00
#29
Jeg kom til at lave en fejl Nu er det OK igen
Kurser inden for grundlæggende programmering