 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

January 23rd, 2004, 01:10 AM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Please look at my code! I get an error message.
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!!!
|
|

January 23rd, 2004, 05:59 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

January 23rd, 2004, 06:47 AM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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...
|
|

January 23rd, 2004, 10:52 AM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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!!!
|
|

January 23rd, 2004, 11:43 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

January 23rd, 2004, 05:26 PM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
"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.
|
|

January 28th, 2004, 02:09 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |