|
 |
asp_databases thread: Help with Incorrect syntax near '='
Message #1 by Anonymous on Sat, 18 Aug 2001 16:22:36 -0700 (PDT)
|
|
Can I do this when I connect to SQL Database using
ASP?
set oRS = oCN.execute("SELECT * FROM vw_Prof WHERE
com_id=" & restID)
That is the line I am getting the error; it says:
Incorrect syntax near '='.
Please help.
Message #2 by "Tomm Matthis" <matthis@b...> on Mon, 20 Aug 2001 06:22:45 -0400
|
|
set the sql string outside of the rs line:
strSQL = "SELECT * FROM vw_Prof WHERE com_id=" & resID &
set oRS = oCN.Execute (strSQL)
Set if that helps...
-- Tomm
> -----Original Message-----
> From: Anonymous Sent: Monday, August 20, 2001 5:24 AM
> To: ASP Databases
> Subject: [asp_databases] Help with Incorrect syntax near '='
>
>
> Can I do this when I connect to SQL Database using
> ASP?
> set oRS = oCN.execute("SELECT * FROM vw_Prof WHERE
> com_id=" & restID)
> That is the line I am getting the error; it says:
> Incorrect syntax near '='.
> Please help.
>
>
Message #3 by Pappas Nikos <pappas@c...> on Mon, 20 Aug 2001 13:39:54 +0300
|
|
Hi
I guess restID is a number.
Is the field restID identity ?
Open enterprise manager ,the database in design view and check this.
I hope it will help because the statement looks fine.
Nikos
At 10:23 рм 20/8/2001 +0100, you wrote:
>Can I do this when I connect to SQL Database using
>ASP?
>set oRS = oCN.execute("SELECT * FROM vw_Prof WHERE
>com_id=" & restID)
>That is the line I am getting the error; it says:
>Incorrect syntax near '='.
>Please help.
>
>
Message #4 by Anonymous on Mon, 20 Aug 2001 08:14:00 -0500
|
|
Try encapsulating restID in single quotes (') like
set oRS = oCN.execute("SELECT * FROM vw_Prof WHERE
> com_id='" & restID & "'")
CFB
> -----Original Message-----
> From: Anonymous Sent: Monday, August 20, 2001 4:24 AM
> To: ASP Databases
> Subject: [asp_databases] Help with Incorrect syntax near '='
>
>
> Can I do this when I connect to SQL Database using
> ASP?
> set oRS = oCN.execute("SELECT * FROM vw_Prof WHERE
> com_id=" & restID)
> That is the line I am getting the error; it says:
> Incorrect syntax near '='.
> Please help.
>
>
Message #5 by avivit@m... on Tue, 21 Aug 2001 07:55:33
|
|
I don'w know about your syntax, does not look good to me.
One thing is for sure: The problem is not with the sql statement, and it
does not matter if u use it as u did or save the sql statement as a
variable.
The following should work for you:
set oCON=server.CreateObject("adodb.connection")
set oRS=server.CreateObject("adodb.recordset")
oCON.open "dsn=yourDsnName"
oRS.Open ("SELECT * FROM vw_Prof WHERE com_id=" & restID), oCON, 3, 3
Message #6 by Steve Carter <Steve.Carter@t...> on Tue, 21 Aug 2001 10:27:41 +0100
|
|
Syntax looks OK to me. The only thing I can think is what was suggested
earlier -
if com_id is a char, varchar, text or string field then you must put quotes
around it in the SQL. E.g. if restID is "hello" then you end up with SQL
being
SELECT * FROM vw_Prof WHERE com_id=hello
where it should be
SELECT * FROM vw_Prof WHERE com_id='hello'
or
SELECT * FROM vw_Prof WHERE com_id="hello"
> -----Original Message-----
>
> Sent: 21 August 2001 08:56
> To: ASP Databases
> Subject: [asp_databases] Re: Help with Incorrect syntax near '='
>
>
> I don'w know about your syntax, does not look good to me.
> One thing is for sure: The problem is not with the sql
> statement, and it
> does not matter if u use it as u did or save the sql statement as a
> variable.
>
> The following should work for you:
>
> set oCON=server.CreateObject("adodb.connection")
> set oRS=server.CreateObject("adodb.recordset")
> oCON.open "dsn=yourDsnName"
> oRS.Open ("SELECT * FROM vw_Prof WHERE com_id=" & restID), oCON, 3,
Message #7 by Kyle Burns <kburns@c...> on Fri, 24 Aug 2001 14:47:51 -0500
|
|
I found that it helps to print your SQL statement to the client and
then
paste the result into the query tool that your DBMS provides to debug
there.
Whenever I run into a syntax error or unexpected results, I do
something
like this...
<!--
<% Response.Write sSQL %>
-->
Then I View...Source on the page and copy the statement to paste into
SQL
Query Analyzer. Sometimes we can be quite surprised at the difference
between the query we think we're building and the query that results.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D
Kyle M. Burns, MCSD
-----Original Message-----
From: Steve Carter
Sent: Tuesday, August 21, 2001 4:28 AM
To: ASP Databases
Subject: [asp_databases] Re: Help with Incorrect syntax near '=3D'
Syntax looks OK to me. The only thing I can think is what was
suggested
earlier -
if com_id is a char, varchar, text or string field then you must put
quotes
around it in the SQL. E.g. if restID is "hello" then you end up with
SQL
being
SELECT * FROM vw_Prof WHERE com_id=3Dhello
where it should be
SELECT * FROM vw_Prof WHERE com_id=3D'hello'
or
SELECT * FROM vw_Prof WHERE com_id=3D"hello"
> -----Original Message-----
> From: avivit@m... [mailto:avivit@m...]
> Sent: 21 August 2001 08:56
> To: ASP Databases
> Subject: [asp_databases] Re: Help with Incorrect syntax near '=3D'
>
>
> I don'w know about your syntax, does not look good to me.
> One thing is for sure: The problem is not with the sql
> statement, and it
> does not matter if u use it as u did or save the sql statement as a
> variable.
>
> The following should work for you:
>
> set oCON=3Dserver.CreateObject("adodb.connection")
> set oRS=3Dserver.CreateObject("adodb.recordset")
> oCON.open "dsn=3DyourDsnName"
> oRS.Open ("SELECT * FROM vw_Prof WHERE com_id=3D" & restID), oCON, 3,
|
|
 |