Fejl i INSERT string
Hej eksperter,jeg har grublet længe over denne kode, kan simplet hen ikke finde fejlen så jeg håber i kan finde den
her er koden:
Først er der et dokument med formen
<body>
<table width="400">
<tr>
<td><form method="post" action="Admin_AddNewsInsertDB.asp">
<table>
<tr>
<td width="20"><input type="radio" value="News" name="Type"></td><td width="50">News</td>
<td width="20"><input type="radio" value="Info" name="Type"></td><td width="50">Info</td>
<td width="20"><input type="radio" value="Announcement" name="Type"></td><td width="90">Announcement</td>
<td width="150"></td>
</tr>
<tr>
<td colspan="7"><input size="65" type="text" name="Headline" value="Headline"></td>
</tr>
<tr>
<td colspan="7"><textarea cols="65" rows="10" type="text" name="Content"></textarea></td>
</tr>
<tr>
<td colspan="7" width="400">
</td>
</tr>
<tr>
<td colspan="4"><input type="submit" value="Submit" name="Submit"><input type="reset" name="reset" value="Cancel"></td>
</tr>
<tr>
<td colspan="4">
<%
Response.Write(Request.QueryString("msg"))
%>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
og dernæst den asp fil som indsætter i Databasen:
Fejl koden:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
Admin_AddNewsInsertDB.asp, line 20
Linje 20 er linje med Conn.Execute
<body>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
conn.connectionstring = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("DB/database.mdb") & ""
Conn.Open connectionstring
set rs = Conn.Execute("SELECT Username FROM Users Where ID= " & Session("ID") & "")
Conn.Execute("Insert into News (Type,Headline,Content,Author,Time,Date) values('" & Request.Form("Type") & "','" & Request.Form("Headline") & "','" & Request.Form("Content") & "','" & rs("Username") & "','" & FormatDateTime(Now, vbShortDate) & "','" & FormatDateTime(Now, vbShortTime) & "')")
strLink = "Admin_AddNews.asp?msg=News%20Added"
Response.Redirect(strLink)
Conn.Close
Set Conn = Nothing
%>
</body>
ville været meget glad hvis i kan finde svaret.