Den här koden ska skriva öva alla ens egna gästboksinlägg till read=1 iställetför read=0 (alla gästboksinlägg har read=0 från början) Ett snabbare och enklare sätt: felet är vad det säger. i ditt fall ska det stå: RecSet("read") = 1, dvs utan hartassar. Har koden så här nu men hur skriver man in Connect.execute(blablablabbblaaa) Såhär bör det bli (du borde byta tillID till ett heltal i databasen!):Mysko fel?
-----------------------------------------------------------------------------
Länken till gastbok1 som ska skriva över medelandena med read=0
Menu1.asp
" target="frame" onMouseOver="swtch('5','guestbook')" onMouseOut="swtch('4','guestbook')">
----------------------------------------------------------------------------
Gastbok1.asp
Koden som ska skriva över medelandena och skicka en vidare till sin egen gästbok. Innehåler det här felet:
ADODB.Recordset error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/muffinman/db/Acomunity/gastbok1.asp, line 10
<!-- # include file="adovbs.inc" -->
<%
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("db/gb.mdb")&";"
Set RecSet = Server.CreateObject("ADODB.Recordset")
Addera = "select * from gb where tillID = '" &Session("ID") & "'"
RecSet.Open Addera, Connect, AdopenKeyset, adLockOptimistic 'Line 10
do while not RecSet.EOF
RecSet("read") = "1"
RecSet.MoveNext
loop
RecSet.Update
RecSet.Close
Connect.close
Set RecSet = nothing
Set Connect = nothing
Response.Redirect "gastbok3.asp?tillID =" & Session("ID")
%>
----------------------------------------------------------------------------------
Gästboks koden:
inehåller inge fel vad jag vet ihjalafal
<!-- #include file="adovbs.inc" -->
<LINK REL=stylesheet HREF="style.css" TYPE="text/css">
<%
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath ("db/gb.mdb")
Set RecSet = Server.CreateObject("ADODB.Recordset")
Addera = "Select * From gb Where tillID = "&Session("ID") &" Order By Datum DESC"
RecSet.Open Addera, Connect, adOpenStatic, adLockOptimistic
%>
<table cellspacing="0" width="410">
<tr>
<td class="boxlooktop" width="410"><p align="center"><b>NAME</b></p>
</tr>
</table>
<table width="584" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="400" class="boxlook">
<% do until recset.EOF %>
<table border="0" width="100%" cellspacing="1" cellpadding="0"><tr>
<td height="10" width="100%"> " target="front"><%=RecSet("namn")%> |
">Svara | ">Delete | <%=RecSet("datum")%>
</td></tr><tr valign="top"><td width="100%">
<table border="0" width="100%" cellspacing="0" cellpadding="2"><tr><td>
" target="front">" width="35" align="left" height="45" border="1">
<%
Dim strMess
strMess = Server.HTMLEncode(RecSet("text"))
strMess = Replace(strMess,"[KOM]","")
strMess = Replace(strMess,"[/KOM]","")
strMess = Replace(strMess,"[Kom]","")
strMess = Replace(strMess,"[/Kom]","")
strMess = Replace(strMess,"[kom]","")
strMess = Replace(strMess,"[/kom]","")
strMess = Replace(strMess,"[B]","<b>")
strMess = Replace(strMess,"[/B]","</b>")
strMess = Replace(strMess,"[b]","<b>")
strMess = Replace(strMess,"[/b]","</b>")
strMess = Replace(strMess,"[I]","<i>")
strMess = Replace(strMess,"[/I]","</i>")
strMess = Replace(strMess,"[i]","<i>")
strMess = Replace(strMess,"[/i]","</i>")
strMess = Replace(strMess,"[U]","<u>")
strMess = Replace(strMess,"[/U]","</u>")
strMess = Replace(strMess,"[u]","<u>")
strMess = Replace(strMess,"[/u]","</u>")
strMess = Replace(strMess,"[LINK]","")
strMess = Replace(strMess,"[/LINK]","")
strMess = Replace(strMess,"[Link]","")
strMess = Replace(strMess,"[/Link]","")
strMess = Replace(strMess,"[link]","")
strMess = Replace(strMess,"[/link]","")
Response.Write strMess
%>
</td></tr></table>
</td></tr></table><br>
<%
RecSet.MoveNext
Loop
RecSet.Close
Connect.Close
Set RecSet = nothing
Set Connect = nothing
%>
</td>
</td>
<td width="165" align="right" rowspan="2">
<table>
<tr>
<td>
<table cellspacing="0">
<tr>
<td class="boxlooktop" width="165"><p align="center"><b>MESSAGE</b></p>
</tr>
</table>
<table width="165" cellpadding="4" cellspacing="0">
<tr>
<td width="155" class="boxlook" align="center">
<form name="form1" method="post" action="gb_spara.asp?tillID=<%=Request.QueryString("tillID")%>">
<input type="hidden" name="Bild" value="<%=Session("Bild")%>">
<textarea name="text" cols="25" rows="4">Sv: Mysko fel?
Connect.Execute "UPDATE gb SET read = 1 where tillID = " & Session("ID")
/JohanSv: Mysko fel?
1. Fel typ, dvs du försöker stoppa in en siffra i ett stringfält, eller en bokstav istället för ett nummer.
2. Du försöker stoppa in ett för stort tal i ett fält / du försöker stoppa in en för stor sträng i ett textfält.Sv: Mysko fel?
men jag håller med Johan. betydligt bättre sätt eftersom du inte behöver hämta något data först.Sv: Mysko fel?
I Databasen har tillID text
<!-- # include file="adovbs.inc" -->
<%
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("db/gb.mdb")&";"
Set RecSet = Server.CreateObject("ADODB.Recordset")
Addera = "select * from gb where tillID = '" & Session("ID") & "'"
RecSet.Open Addera, Connect, AdopenKeyset, adLockOptimistic
do while not RecSet.EOF
RecSet("read") = 1
RecSet.MoveNext
loop
RecSet.Update
RecSet.Close
Connect.close
Set RecSet = nothing
Set Connect = nothing
Response.Redirect "gastbok3.asp?tillID =" & Session("ID")
%>
Sv: Mysko fel?
<code>
<!-- # include file="adovbs.inc" -->
<%
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("db/gb.mdb")&";"
Connect.Execute "UPDATE gb SET read = 1 WHERE tillID = '" & Session("ID") & "'"
Connect.close
Set Connect = nothing
Response.Redirect "gastbok3.asp?tillID =" & Session("ID")
%>
</code>