|
Subject:
|
Please look at my code! I get an error message.
|
|
Posted By:
|
stacy
|
Post Date:
|
1/23/2004 12:10:41 AM
|
I hope someone can help me, as it's frustrating me greatly! This is the messed up part of the code:
Else Response.Write _ "<CENTER><H1>Mercy School<BR>Edit News</H1></CENTER>" & _ "<P>Please edit the information for this current news. " Dim rsNews Set rsNews = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT * FROM News WHERE NewsID = " & Request("News") & ";" rsNews.Open strSQL, objConn, adOpenForwardOnly, adLockOptimistic, adCmdText End If
and this is the error i get:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'NewsID ='.
/stacygraff/News.asp, line 30
Can someone please tell me what's wrong with it???
Thank you!!!
|
|
Reply By:
|
KenSchaefer
|
Reply Date:
|
1/23/2004 4:59:45 AM
|
Before: rsNews.Open strSQL, objConn, adOpenForwardOnly, adLockOptimistic, adCmdText put the following code:
Response.Write(strSQL) Response.End
I think it will be pretty obvious what the problem is then. If you are still having issues consult: www.adOpenStatic.com/faq/80040e14.asp
Cheers Ken
Microsoft MVP - Windows Server (IIS) www.adOpenStatic.com
|
|
Reply By:
|
alex_read
|
Reply Date:
|
1/23/2004 5:47:57 AM
|
WHERE NewsID = " & Request("News") & ";"
Change this statement to read: WHERE NewsID = '" & Request("News") & "';"
(or if the NewsID field is numerical, use a cint() function to alter the data type). The database is having a problem recognising the data type you're passing in. If it's a string value, enclose it in single quotes as above...
|
|
Reply By:
|
stacy
|
Reply Date:
|
1/23/2004 9:52:44 AM
|
Ken-This is what I get after I do what you said.
Please edit the information for this current news. SELECT * FROM News WHERE NewsID = ;
(PLease keep in mind: NOTHING is obvious in ASP to ME...I'm really new to this!)
Thanks for your help!!!
|
|
Reply By:
|
pgtips
|
Reply Date:
|
1/23/2004 10:43:26 AM
|
Request("News") is empty, so no value is being passed to the where clause, its just left hanging without a value to compare against.
Where is Request("News") supposed to come from? Is it POSTed from another asp page, or maybe passed as a parameter in the querystring?
You can add a test like this so you won't get the error, but you won't see any records until you fix this issue: If Len("" & Request("News")) = 0 Then Response.Write "News ID not received" Else Dim rsNews Set rsNews = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT * FROM News WHERE NewsID = " & Request("News") & ";" rsNews.Open strSQL, objConn, adOpenForwardOnly, adLockOptimistic, adCmdText ... End If
hth Phil
|
|
Reply By:
|
stacy
|
Reply Date:
|
1/23/2004 4:26:03 PM
|
"News" is a table in my database. User will see the contents of the table "news" on "viewnews.asp". When they click the newsID, it should go to a page to edit that record. That's where "News" is coming from.
|
|
Reply By:
|
KenSchaefer
|
Reply Date:
|
1/28/2004 1:09:49 AM
|
You need to pass the NewsID from one page to the next, eg in the first page:
<a href="edit.asp?newsId=1">click to edit item 1</a>
then request.querystring("newsID") will contain the value "1" on page 2.
Cheers Ken
Microsoft MVP - Windows Server (IIS) www.adOpenStatic.com
|