Jag vill at en kod ska delite en kompis i en community men den vill inte ta bort kompisen. Bort="DELETE * FROM friends WHERE ID=" & Session("ID") & " AND ID=" & Request.Querystring("ID") hur menar du? Du menar att den ska se ut så här? Nu blir det felmedelandet i delite kodenDelite
Sida som tar bort:
<% If Request.Querystring("vad")="tabort" Then
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("db/friends.mdb")&";"
Bort="DELETE * FROM friends WHERE ID=" & Session("ID") & " AND ID=" & Request.Querystring("ID")
Connect.Execute(Bort)
Connect.Close
Set Connect = Nothing
Response.Redirect "friends.asp?ID1=" & Session("ID")
End If %>
Sida där dom ska tas bort ifrån:
<!-- #include file="adovbs.inc" -->
<%
If Session("login") <> "ok" Then
Session("meddelande") = "You have to be online!"
Response.Redirect "login.asp"
End If
%>
<%
Set Connect2 = Server.CreateObject("ADODB.Connection")
Connect2.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("db/db.mdb")&";"
Set RecSet2 = Server.CreateObject("ADODB.Recordset")
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("db/friends.mdb")&";"
Set RecSet = Server.CreateObject("ADODB.Recordset")
Addera = "Select * From friends Where ID1 = '"&Session("ID") & "'"
RecSet.Open Addera, Connect, adOpenStatic, adLockOptimistic
%>
<html>
<head>
<LINK REL=stylesheet HREF="style.css" TYPE="text/css">
<title>Registrera användare</title>
</head>
<body>
<DIV align="center">
<table width="197" cellspacing="0">
<tr>
<td background="images/friends.gif" align="center" width="249" height="20"><b>FRIENDS</b>
</tr>
<tr>
<td class="boxlook" valign="top" width="249" height="160">
<%Do Until RecSet.EOF%>
<%Addera2 = "Select * From tblUsers Where ID = "&RecSet("ID2")
RecSet2.Open Addera2, Connect2, adOpenStatic, adLockOptimistic
%>
">"> " target="front"><%=RecSet("username")%> <%if recset2("Status") = "online" then%> <img src="images/online.gif" width="8" height="8" alt="<%=RecSet("username")%> is online"> <%else%> <img src="images/offline.gif" width="8" height="8" alt="<%=RecSet("username")%> is offline"> <%end if%><br>
<%
RecSet2.Close
RecSet.MoveNext
Loop
Connect2.Close
Set RecSet2 = nothing
Set Connect2 = nothing
RecSet.Close
Connect.Close
Set RecSet = nothing
Set Connect = nothing
%>
<br>
</tr>
</table>
</DIV>
</body>
</html> Sv: Delite
Där har du nog problemet, fältet ID är inte lika med två olika värden samtidigt (om nu inte sessionvariabeln och querystringen har samma värde).
/JohanSv: Delite
I friend.mdb finns dom här raderna
ID = Håller räkning på alla kompisar i databasen
ID1 = Spara ID på personen som skaffar en ny kompis
ID2 = ID:nr på kompisen
Username = = Namntet på kopisenSv: Delite
Bort ="DELETE * FROM friends WHERE ID1=" & Session("ID") & " AND ID2=" & Request.Querystring("ID") Sv: Delite
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
/muffinman/db/Acomunity/delite.asp, line 5