Vad é fel? Följande kod fungerar i VB6 :Felmedelande
ALLA:
FELMEDELANDE:
ADODB.Recordset fel '800a0cb3'
Objektet eller providern kan inte utföra den begärda åtgärden.
/sidan/mail/las.asp, rad 44
KOD:
<!--#include virtual="/sidan/adovbs.inc" -->
<!--#include virtual="/sidan/check.asp" -->
<HTML>
<HEAD>
<TITLE>Mitt community</TITLE>
</HEAD>
<BODY>
<%
Function bytut(text)
text = Replace(text, Chr(13), "<BR>")
bytut = text
End Function
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("/sidan/db/users.mdb")
Set RecSet = Server.CreateObject("ADODB.Recordset")
Sql = "Select * From mails Where ID = " & request.querystring("id")
Set RecSet = Conn.Execute(Sql)
If Not RecSet("Till") = Session("user") Then
Response.Redirect "Inbox.asp"
End If %>
Från <%=RecSet("Fran")%><BR>
Mess:<br><br>
<%=bytut(RecSet("Medelande"))%><BR> <BR>
">Tabort
- &titel=<%=RecSet("titel")%>">Svara
- inbox
<%
If RecSet("Last") = "Nej" Then
RecSet("Last") = "Ja"
End If
RecSet.Update
RecSet.Close
Conn.Close
Set RecSet=Nothing
Set Conn=Nothing
%>
</body>
</html>
RAD:
RecSet.UpdateSv: Felmedelande
Skillnaden ligger i att använda RecSet.Open i st för conn.Execute så att du kan sätta rätt cursor och Locking-metod...
<code>
Dim conn As ADODB.Connection
Dim RecSet As ADODB.Recordset
Dim sql As String
Set conn = New ADODB.Connection
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=c:\temp\db2.mdb"
Set RecSet = New ADODB.Recordset
sql = "Select * From mails Where ID = 1"
RecSet.Open sql, conn, adOpenDynamic, adLockOptimistic ' sql,conn,2,3
' Set RecSet = conn.Execute(sql, Options:=adOpenDynamic)
If RecSet("Last") = False Then
RecSet("Last") = True
End If
RecSet.Update
RecSet.Close
conn.Close
Set RecSet = Nothing
Set conn = Nothing
</code>
/Per Hultqvist