I ran this code in access and it works.
We just recently moved to sql server, now I am getting two errors.
The first is:
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'AND'.
and the code is:
rsget.Open "SELECT * FROM board WHERE ThreadID= "&id&" AND ThreadP=0", conn
and the second is:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '8'.
and the code is not even inserting anything into the sql server db.
<%
response.buffer = true
topic = Replace(Server.HTMLEncode(Request.Form("topic"),"'","''"
name = Replace(Server.HTMLEncode(Request.Form("name"),"'","''"
email = Replace(Server.HTMLEncode(Request.Form("email"),"'","''"
http = Replace(Server.HTMLEncode(Request.Form("http"),"'", "''"
body = Request.Form("body"
body = Replace(body , "'", "''"
body = Replace(body, vbcrlf, "<br>"
if topic = "" OR name = "" OR body = "" then
Response.Redirect("post.asp?error=1"
end if
if instr(LCase(body), "<script" <> 0 then
Response.Redirect("post.asp?error=2"
end if
if email <> "" then
if instr(email, "@" = 0 OR instr(email, "." = 0 then
Response.Redirect("post.asp?error=3"
end if
end if
if http <> "" then
if instr(http, " = 0 OR instr(http, "." = 0 then
Response.Redirect("post.asp?error=4"
end if
end if
set conn = Server.CreateObject("ADODB.connection"
conn.open "DSN=BBoard"
sqlstring = "INSERT INTO board ( tdate, topic, name, email, http, body ) " &_
"values ( # " &now()& " #, ' " &topic& " ' , ' " &name& " ' , ' " &email& " ', ' " &http& " ' , ' " &body& " ')"
conn.Execute(sqlstring)
conn.Close
set conn = Nothing
Response.redirect "default.asp"
%>
We just recently moved to sql server, now I am getting two errors.
The first is:
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'AND'.
and the code is:
rsget.Open "SELECT * FROM board WHERE ThreadID= "&id&" AND ThreadP=0", conn
and the second is:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '8'.
and the code is not even inserting anything into the sql server db.
<%
response.buffer = true
topic = Replace(Server.HTMLEncode(Request.Form("topic"),"'","''"
name = Replace(Server.HTMLEncode(Request.Form("name"),"'","''"
email = Replace(Server.HTMLEncode(Request.Form("email"),"'","''"
http = Replace(Server.HTMLEncode(Request.Form("http"),"'", "''"
body = Request.Form("body"
body = Replace(body , "'", "''"
body = Replace(body, vbcrlf, "<br>"
if topic = "" OR name = "" OR body = "" then
Response.Redirect("post.asp?error=1"
end if
if instr(LCase(body), "<script" <> 0 then
Response.Redirect("post.asp?error=2"
end if
if email <> "" then
if instr(email, "@" = 0 OR instr(email, "." = 0 then
Response.Redirect("post.asp?error=3"
end if
end if
if http <> "" then
if instr(http, " = 0 OR instr(http, "." = 0 then
Response.Redirect("post.asp?error=4"
end if
end if
set conn = Server.CreateObject("ADODB.connection"
conn.open "DSN=BBoard"
sqlstring = "INSERT INTO board ( tdate, topic, name, email, http, body ) " &_
"values ( # " &now()& " #, ' " &topic& " ' , ' " &name& " ' , ' " &email& " ', ' " &http& " ' , ' " &body& " ')"
conn.Execute(sqlstring)
conn.Close
set conn = Nothing
Response.redirect "default.asp"
%>