Fejl ved opdatering af DB
"[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression"Jeg får den fejl, og tabellerne passer, har hvertfald tjekket flere gange, her er min kode:
<%if session("LOGIN") = 0 then
this_page = request.ServerVariables("URL")
Response.Redirect("login.asp?page=" & this_page)
end if%>
<% if Request.QueryString("mode")="" then %>
<html>
<title>News - Rediger</title>
<head>
<style type="text/css">
h1 {font-size: 15px; font-family: verdana;}
p {font-size: 10px; font-family: "verdana";}
</style>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" width="500">
<tr>
<td colspan="2"><b><p><font size="4">Rediger</font></p></b></td>
</tr>
<tr>
<td colspan="2"><p align="center"><!--#include file="menu.asp"--><br><br></p></td>
</tr>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSN = DSN & "DBQ=" & Server.MapPath("/db/db.mdb")
Conn.Open DSN
strSQL = "Select * from Nyheder where Id = " & Request.Querystring("id")
Set rs = Conn.Execute(strSQL)
%>
<form method="post" Action="rediger.asp?mode=ca&id=<%= rs("id") %>">
<tr>
<td width="50%"><p>Titel:</p></td>
<td width="50%"><input type="text" name="Titel" value="<%= rs("Titel") %>"></td>
</tr>
<tr>
<td width="50%"><p>Content:</p></td>
<td width="50%"><textarea name="Indhold" cols="60" rows="6"><%= rs("Indhold") %></textarea></td>
</tr>
<tr>
<td width="50%"></td>
<td width="50%"><input type="submit" name="submit" value="Update"></td>
</tr>
</form>
<% end if
if Request.QueryString("mode")="ca" then
Titel = Request.Form("Titel")
Indhold = Request.Form("Indhold")
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSN = DSN & "DBQ=" & Server.MapPath("/db/db.mdb")
Conn.Open DSN
strSQL = "Update nyheder set "
strSQL = strSQL & "Titel= '" & Titel & "', "
strSQL = strSQL & "Indhold= '" & Indhold & "' "
strSQL = strSQL & " Where Id = '" & Request.QueryString("id")
Conn.Execute(strSQL)
Response.Redirect("oversigt.asp")
Conn.Close
Set Conn = Nothing
end if
%>
fejlen sker i linje 62 som er:
strSQL = "Update nyheder set "
strSQL = strSQL & "Titel= '" & Titel & "', "
strSQL = strSQL & "Indhold= '" & Indhold & "' "
strSQL = strSQL & " Where Id = '" & Request.QueryString("id")
Conn.Execute(strSQL)