Ask a Question related to ASP Database, Design and Development.
-
Wayne... #1
SQL statement error
when I use the following select statment and code:
<% blah blah etc etc.....
Set rsCodevault = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM asp WHERE id = " & ID
rsCodevault.Open strSQL, adoCon
%>
I get the following error..........
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/ShowMessage.asp, line 9
strSQL = "SELECT * FROM asp WHERE id = " & ID;
---------------------------------------------^
I know it's something simple but I been awake 36 hours striaght and this
might jusdt enable me to get some sleep.
Thanks in advance
Wayne...
Wayne... Guest
-
Update Statement error
Hello, Ii'm receiving the syntax error listed below for my update statement. Doesn't anyone have any ideas? Syntax error or access... -
Syntax error in Where Statement
Having a problem with what the server says is a syntax error in the Where statement, but cant figure out where it is. <cfif ... -
SQL error in DELETE statement
I am working on a page that deletes a record from a database. Everything seems to be right to me and I can't figure out what is wrong. The SQL is... -
Syntax Error Update Statement
Can someone tell me what's wrong with this code? I need help. Thanks! It is an update page. FIRST PAGE: LOGIN CHECK <!--- Filename: ... -
Error when using include statement
1. You have the first line commented out 2. you are not embedding quotes properly. Try (multiple lines to avoid email problems): ... -
Aaron [SQL Server MVP] #2
Re: SQL statement error
VBScript does not use ; as a statement terminator.
--
[url]http://www.aspfaq.com/[/url]
(Reverse address to reply.)
"Wayne..." <wayne@secretwebdesign.com> wrote in message
news:40be2f49@212.67.96.135...> when I use the following select statment and code:
>
>
> <% blah blah etc etc.....
>
> Set rsCodevault = Server.CreateObject("ADODB.Recordset")
> strSQL = "SELECT * FROM asp WHERE id = " & ID
> rsCodevault.Open strSQL, adoCon
> %>
>
> I get the following error..........
>
> Microsoft VBScript compilation error '800a0401'
>
> Expected end of statement
>
> /ShowMessage.asp, line 9
>
> strSQL = "SELECT * FROM asp WHERE id = " & ID;
> ---------------------------------------------^
> I know it's something simple but I been awake 36 hours striaght and this
> might jusdt enable me to get some sleep.
> Thanks in advance
>
> Wayne...
>
>
Aaron [SQL Server MVP] Guest
-
Wayne... #3
Re: SQL statement error
ok I tried that now get this:
Error Type:
Provider (0x80004005)
Unspecified error
/codevault/ShowMessage.asp, line 7
wayne...
"Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
news:uztFerNSEHA.2000@TK2MSFTNGP11.phx.gbl...> VBScript does not use ; as a statement terminator.
>
> --
> [url]http://www.aspfaq.com/[/url]
> (Reverse address to reply.)
>
>
>
>
> "Wayne..." <wayne@secretwebdesign.com> wrote in message
> news:40be2f49@212.67.96.135...>> > when I use the following select statment and code:
> >
> >
> > <% blah blah etc etc.....
> >
> > Set rsCodevault = Server.CreateObject("ADODB.Recordset")
> > strSQL = "SELECT * FROM asp WHERE id = " & ID
> > rsCodevault.Open strSQL, adoCon
> > %>
> >
> > I get the following error..........
> >
> > Microsoft VBScript compilation error '800a0401'
> >
> > Expected end of statement
> >
> > /ShowMessage.asp, line 9
> >
> > strSQL = "SELECT * FROM asp WHERE id = " & ID;
> > ---------------------------------------------^
> > I know it's something simple but I been awake 36 hours striaght and this
> > might jusdt enable me to get some sleep.
> > Thanks in advance
> >
> > Wayne...
> >
> >
>
Wayne... Guest
-
Bob Barrows [MVP] #4
Re: SQL statement error
Do a Response.Write strsql so we can see the query being sent to the
database.
Bob Barrows
Wayne... wrote:--> ok I tried that now get this:
> Error Type:
> Provider (0x80004005)
> Unspecified error
> /codevault/ShowMessage.asp, line 7
>
>
> wayne...
>
>
> "Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
> news:uztFerNSEHA.2000@TK2MSFTNGP11.phx.gbl...>> VBScript does not use ; as a statement terminator.
>>
>> --
>> [url]http://www.aspfaq.com/[/url]
>> (Reverse address to reply.)
>>
>>
>>
>>
>> "Wayne..." <wayne@secretwebdesign.com> wrote in message
>> news:40be2f49@212.67.96.135...>>> when I use the following select statment and code:
>>>
>>>
>>> <% blah blah etc etc.....
>>>
>>> Set rsCodevault = Server.CreateObject("ADODB.Recordset")
>>> strSQL = "SELECT * FROM asp WHERE id = " & ID
>>> rsCodevault.Open strSQL, adoCon
>>> %>
>>>
>>> I get the following error..........
>>>
>>> Microsoft VBScript compilation error '800a0401'
>>>
>>> Expected end of statement
>>>
>>> /ShowMessage.asp, line 9
>>>
>>> strSQL = "SELECT * FROM asp WHERE id = " & ID;
>>> ---------------------------------------------^
>>> I know it's something simple but I been awake 36 hours striaght and
>>> this might jusdt enable me to get some sleep.
>>> Thanks in advance
>>>
>>> Wayne...
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Bob Barrows [MVP] Guest
-
Wayne... #5
Re: SQL statement error
ok I've made a page with the following code: (this is gonnna be long but
thought it best to givce all the info, btw the code is in memo feild types)
HTML page [index2.asp]
-----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Code Vault </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="codevault.css">
</head>
<body>
<h1>Latest Code </h1>
<h2>ASP.net</h2>
<p>Title<br />
Author</p>
<h2>ASP</h2>
<p>
<!--#include file="asp2.asp" -->
</p>
<h2>CSS</h2>
<p>Title<br />
Author</p>
<h2>PHP</h2>
<p>Title<br />
Author</p>
<h2>Tips</h2>
<p>Title<br />
Author</p>
<h2>Layout</h2>
<p>Title<br />
Author</p>
</body>
</html>
-----------------
ASP2.asp code:
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsCodevault 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less
connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("codevault.mdb")
'Create an ADO recordset object
Set rsCodevault = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
with
strSQL = "SELECT * FROM asp;"
'Open the recordset with the SQL query
rsCodevault.Open strSQL, adoCon
'Loop through the recordset
Do While not rsCodevault.EOF
'Write the HTML to display the contents of the recordset
'testing out an idea of putting the id into a variable and passiong it to
new page
Response.Write ("<br>")
Response.Write ("<b>Title: </b>")
response.write ("<A HREF='test.asp?ID=" & rsCodevault("id") & "'>" &
rsCodevault("title") & "</A>")
Response.Write ("<br>")
Response.Write ("<b>Author: </b>")
Response.Write (rsCodevault("author"))
Response.Write ("<br>")
'Move to the next record in the recordset
rsCodevault.MoveNext
Loop
'Reset server variables
rsCodevault.Close
Set rsCodevault = Nothing
Set adoCon = Nothing
%>
-----------------------
ShowMessage.asp code:
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsCodevault 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("codevault.mdb")
Set rsCodevault = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM asp WHERE id = " & ID
rsCodevault.Open strSQL, adoCon
%>
<HTML>
<HEAD>
<TITLE>Codevault </TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<link href="codecss.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY BGCOLOR = "#FFFFFF">
<CENTER><H2>ASP Code</H2></CENTER>
Response.Write strsql
%>
<%
rsCodevault.Close
Set rsCodevault = Nothing
Set adoCon = Nothing
%>
</body>
</html>
---------------------
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 'id ='.
/test.asp, line 10
thanks for taking the time to help : )
Wayne...
Wayne... Guest
-
Bob Barrows [MVP] #6
Re: SQL statement error
Give me a break. :-)
I asked you to show us the result of Response.Write strSQL and you give us
the whole flipping page? No, 3 pages! HTML and all??! And nowhere do I see
the result of Response.Write strSQL, unless it's hidden somewhere in that
morass of code!
Look, you're having a vbscript/ado/asp problem. The only thing that's
relevant to show us is vbscript code :-)
More below:
Wayne... wrote:<snippety-snip>> ok I've made a page with the following code: (this is gonnna be long
> but thought it best to givce all the info, btw the code is in memo
> feild types)Let's start here. Don't use ODBC when there's a perfectly good OLEDB> <%
> 'Dimension variables
> Dim adoCon 'Holds the Database Connection Object
> Dim rsCodevault 'Holds the recordset for the records in the
> database Dim strSQL 'Holds the SQL query to query the
> database
> Set adoCon = Server.CreateObject("ADODB.Connection")
> adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
>
> Server.MapPath("codevault.mdb")
provider for Jet:
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("codevault.mdb")
You have not assigned a value to that ID variable anywhere that I can see.> Set rsCodevault = Server.CreateObject("ADODB.Recordset")
> strSQL = "SELECT * FROM asp WHERE id = " & ID
Where is the value supposed to come from?
Incidently, that Response.Write statement should be here. It's purely for
debugging purposes: once you have everything working you can delete or
comment it out.
Also, don't be lazy! Don't use selstar (Select *) in production code.
Explicitly list the names of the fields you want your query to return. When
you use selstar, you are retrieving all the fields when you probably only
need a subset of the fields. And even if you do need all the fields, you are
hurting performance because you are forcing ado to make an extra trip to the
database to figure out what * means.
should be:> rsCodevault.Open strSQL, adoCon,,,1
rsCodevault.Open strSQL, adoCon,,,1
Again, this is a performance improvement suggestion.
<snip> <HTML>> %>Oh! Here it is!! Ummm - this needs to be in your server-side code block> <HEAD>
> <TITLE>Codevault </TITLE>
> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;
> charset=ISO-8859-1"> <link href="codecss.css" rel="stylesheet"
> type="text/css"> </HEAD>
> <BODY BGCOLOR = "#FFFFFF">
> <CENTER><H2>ASP Code</H2></CENTER>
> Response.Write strsql
(Response is a server-side object), preferably right after the line that
assigns the sql statement to the strsql variable.
Now, it's obvious that the value for id is not making its way to this query> ---------------------
> 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 'id ='.
>
> /test.asp, line 10
>
statement.
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Bob Barrows [MVP] Guest
-
Jeff Cochran #7
Re: SQL statement error
On Thu, 3 Jun 2004 00:05:48 +0100, "Wayne..."
<wayne@secretwebdesign.com> wrote:
Yet you missed answering the question we asked. Show us the strSQL>ok I've made a page with the following code: (this is gonnna be long but
>thought it best to givce all the info, btw the code is in memo feild types)
output.
This page is probably generating your error, even though it doesn't
match the error you posted (none do, you renamed the code you posted
so it doesn't match the error message...):
Here's your SQL query:><%
>'Dimension variables
>Dim adoCon 'Holds the Database Connection Object
>Dim rsCodevault 'Holds the recordset for the records in the database
>Dim strSQL 'Holds the SQL query to query the database
>Set adoCon = Server.CreateObject("ADODB.Connection")
>adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
>
>Server.MapPath("codevault.mdb")
>Set rsCodevault = Server.CreateObject("ADODB.Recordset")
When you do a>strSQL = "SELECT * FROM asp WHERE id = " & ID
Response.Write strSQL
And show us the code, we'll see:
SELECT * FROM asp WHERE id =
Which results in the error:
Which is because the SQL Query has a syntax error, since you're>Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
>
>[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in
>query expression 'id ='.
comparing id to... Well, there's nothing there, is there?
Now, go back and do the Responnse.Write yourself to prove it, then
tell us where you think that the value "ID" is coming from?
Hint: Add a "Response.Write ID" in your code and you'll find you
never populate the variable ID. I can tell this since the code above
your query being executed has absolutely no reference to the variable.
Jeff
Jeff Cochran Guest
-
dave #8
Re: SQL statement error
At least the code is in there - now you need to run the page ;-)
<BODY BGCOLOR = "#FFFFFF">
<CENTER><H2>ASP Code</H2></CENTER>
Response.Write strsql
%>
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:O4XG11PSEHA.3848@TK2MSFTNGP09.phx.gbl...When> Give me a break. :-)
> I asked you to show us the result of Response.Write strSQL and you give us
> the whole flipping page? No, 3 pages! HTML and all??! And nowhere do I see
> the result of Response.Write strSQL, unless it's hidden somewhere in that
> morass of code!
>
> Look, you're having a vbscript/ado/asp problem. The only thing that's
> relevant to show us is vbscript code :-)
> More below:
>
> Wayne... wrote:> <snippety-snip>> > ok I've made a page with the following code: (this is gonnna be long
> > but thought it best to givce all the info, btw the code is in memo
> > feild types)>> > <%
> > 'Dimension variables
> > Dim adoCon 'Holds the Database Connection Object
> > Dim rsCodevault 'Holds the recordset for the records in the
> > database Dim strSQL 'Holds the SQL query to query the
> > database
> > Set adoCon = Server.CreateObject("ADODB.Connection")
> > adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
> >
> > Server.MapPath("codevault.mdb")
> Let's start here. Don't use ODBC when there's a perfectly good OLEDB
> provider for Jet:
>
> adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data Source=" & Server.MapPath("codevault.mdb")
>
>>> > Set rsCodevault = Server.CreateObject("ADODB.Recordset")
> > strSQL = "SELECT * FROM asp WHERE id = " & ID
> You have not assigned a value to that ID variable anywhere that I can see.
> Where is the value supposed to come from?
>
> Incidently, that Response.Write statement should be here. It's purely for
> debugging purposes: once you have everything working you can delete or
> comment it out.
>
> Also, don't be lazy! Don't use selstar (Select *) in production code.
> Explicitly list the names of the fields you want your query to return.are> you use selstar, you are retrieving all the fields when you probably only
> need a subset of the fields. And even if you do need all the fields, youthe> hurting performance because you are forcing ado to make an extra trip toquery> database to figure out what * means.
>>> > rsCodevault.Open strSQL, adoCon,,,1
> should be:
> rsCodevault.Open strSQL, adoCon,,,1
>
> Again, this is a performance improvement suggestion.
>> <snip> <HTML>> > %>>> > <HEAD>
> > <TITLE>Codevault </TITLE>
> > <META HTTP-EQUIV="Content-Type" CONTENT="text/html;
> > charset=ISO-8859-1"> <link href="codecss.css" rel="stylesheet"
> > type="text/css"> </HEAD>
> > <BODY BGCOLOR = "#FFFFFF">
> > <CENTER><H2>ASP Code</H2></CENTER>
> > Response.Write strsql
> Oh! Here it is!! Ummm - this needs to be in your server-side code block
> (Response is a server-side object), preferably right after the line that
> assigns the sql statement to the strsql variable.
>
>>> > ---------------------
> > 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 'id ='.
> >
> > /test.asp, line 10
> >
> Now, it's obvious that the value for id is not making its way to this> statement.
>
> Bob Barrows
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>
dave Guest
-
Wayne... #9
Re: SQL statement error
thanks to all I've managed to sort out the mess and everything now works
fine. Turned out that as well as not getting the id variable that was
passed the connection was flakey. would drop if you tried to refresh the
page....
So I changed the connection to the type recommended - problem solved!
Wayne...
Wayne... Guest



Reply With Quote

