Professional Web Applications Themes

Syntax error - Macromedia ColdFusion

I posted a question or two on this recently, and posts have been helpful. However, I have a new problem, and don't know what to do. To recap. Simple page, this page is what gets shown when the previous page, which contains a form, is submitted using Post. First thing I want to do is insert a row into the database, called Shape, and the table in question is called Personal. First, the code: strFirstName = Replace(Trim(Request.Form("FirstName")),"'","''") strLastName = Replace(Trim(Request.Form("LastName")),"'","''") strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\Grace\Shape.mdb;User Id=admin;Password=;" Set objConnection = Server.CreateObject("ADODB.Connection") objConnection.ConnectionString = strConnection objConnection.Open strSQL = "INSERT INTO Personal(FirstName,LastName) VALUES ('"&strFirstName&"','"&strLastName&"')" ...

  1. #1

    Default syntax error

    I posted a question or two on this recently, and posts have been helpful.
    However, I have a new problem, and don't know what to do.

    To recap. Simple page, this page is what gets
    shown when the previous page, which contains a form, is submitted using
    Post. First thing I want to do is insert a row into the database, called
    Shape, and the table in question is called Personal.
    First, the code:

    strFirstName = Replace(Trim(Request.Form("FirstName")),"'","''")
    strLastName = Replace(Trim(Request.Form("LastName")),"'","''")

    strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=C:\Inetpub\wwwroot\Grace\Shape.mdb;User Id=admin;Password=;"

    Set objConnection = Server.CreateObject("ADODB.Connection")
    objConnection.ConnectionString = strConnection
    objConnection.Open

    strSQL = "INSERT INTO Personal(FirstName,LastName) VALUES
    ('"&strFirstName&"','"&strLastName&"')"
    Set rs = Server.CreateObject( "ADODB.Recordset" )
    rs.Open strSQL, objConnection,

    Set rs = objConnection.Execute( sql )
    objConnection.Close

    rs.Close
    Set rs = Nothing
    ----------------------------------
    I was getting another error, but the advice was to allow IUSR to have proper
    permissions,. which I did. Now, i get this error:

    Microsoft VBScript compilation (0x800A03EA)
    Syntax error
    /grace/shapethankyou.asp, line 152, column 30
    rs.Open strSQL, objConnection,
    -----------------------------^





    middletree Guest

  2. #2

    Default Re: syntax error

    The error is pointing right to the issue, and that is that you have a
    trailing comma that shouldn't be there. But, really, you have a couple of
    lines of code that shouldn't be there. Remove these lines from your code

    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open, strSQL, objConnection, <--that comma, btw

    Those lines are unnecessary. After removing them, delete this line
    Set rs = objConnection.Execute( sql ) ''wouldn't this have been strSQL?

    And replace it with
    objConnection.Execute strSQL


    There is no need to create an RS when doing an insert.

    Ray at work

    --
    Will trade ASP help for SQL Server help


    "middletree" <middletreehtomail.com> wrote in message
    news:%23EHqXr1cDHA.1728TK2MSFTNGP09.phx.gbl...
    > I posted a question or two on this recently, and posts have been helpful.
    > However, I have a new problem, and don't know what to do.
    >
    > To recap. Simple page, this page is what gets
    > shown when the previous page, which contains a form, is submitted using
    > Post. First thing I want to do is insert a row into the database, called
    > Shape, and the table in question is called Personal.
    > First, the code:
    >
    > strFirstName = Replace(Trim(Request.Form("FirstName")),"'","''")
    > strLastName = Replace(Trim(Request.Form("LastName")),"'","''")
    >
    > strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    > Source=C:\Inetpub\wwwroot\Grace\Shape.mdb;User Id=admin;Password=;"
    >
    > Set objConnection = Server.CreateObject("ADODB.Connection")
    > objConnection.ConnectionString = strConnection
    > objConnection.Open
    >
    > strSQL = "INSERT INTO Personal(FirstName,LastName) VALUES
    > ('"&strFirstName&"','"&strLastName&"')"
    > Set rs = Server.CreateObject( "ADODB.Recordset" )
    > rs.Open strSQL, objConnection,
    >
    > Set rs = objConnection.Execute( sql )
    > objConnection.Close
    >
    > rs.Close
    > Set rs = Nothing
    > ----------------------------------
    > I was getting another error, but the advice was to allow IUSR to have
    proper
    > permissions,. which I did. Now, i get this error:
    >
    > Microsoft VBScript compilation (0x800A03EA)
    > Syntax error
    > /grace/shapethankyou.asp, line 152, column 30
    > rs.Open strSQL, objConnection,
    > -----------------------------^
    >
    >
    >
    >
    >

    Ray at Guest

  3. #3

    Default Re: syntax error

    Ray at <%=sLocation%> wrote:
    > And replace it with
    > objConnection.Execute strSQL
    To be completely correct, I would recommend this:
    objConnection.Execute strSQL,,129


    Bob Barrows Guest

  4. #4

    Default Re: syntax error

    Makes sense when you say it.

    thanks


    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:uwFvpU2cDHA.2416TK2MSFTNGP10.phx.gbl...
    > The error is pointing right to the issue, and that is that you have a
    > trailing comma that shouldn't be there. But, really, you have a couple of
    > lines of code that shouldn't be there. Remove these lines from your code
    >
    > Set rs = Server.CreateObject("ADODB.Recordset")
    > rs.Open, strSQL, objConnection, <--that comma, btw
    >
    > Those lines are unnecessary. After removing them, delete this line
    > Set rs = objConnection.Execute( sql ) ''wouldn't this have been strSQL?
    >
    > And replace it with
    > objConnection.Execute strSQL
    >
    >
    > There is no need to create an RS when doing an insert.
    >
    > Ray at work
    >
    > --
    > Will trade ASP help for SQL Server help
    >
    >
    > "middletree" <middletreehtomail.com> wrote in message
    > news:%23EHqXr1cDHA.1728TK2MSFTNGP09.phx.gbl...
    > > I posted a question or two on this recently, and posts have been
    helpful.
    > > However, I have a new problem, and don't know what to do.
    > >
    > > To recap. Simple page, this page is what gets
    > > shown when the previous page, which contains a form, is submitted using
    > > Post. First thing I want to do is insert a row into the database, called
    > > Shape, and the table in question is called Personal.
    > > First, the code:
    > >
    > > strFirstName = Replace(Trim(Request.Form("FirstName")),"'","''")
    > > strLastName = Replace(Trim(Request.Form("LastName")),"'","''")
    > >
    > > strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    > > Source=C:\Inetpub\wwwroot\Grace\Shape.mdb;User Id=admin;Password=;"
    > >
    > > Set objConnection = Server.CreateObject("ADODB.Connection")
    > > objConnection.ConnectionString = strConnection
    > > objConnection.Open
    > >
    > > strSQL = "INSERT INTO Personal(FirstName,LastName) VALUES
    > > ('"&strFirstName&"','"&strLastName&"')"
    > > Set rs = Server.CreateObject( "ADODB.Recordset" )
    > > rs.Open strSQL, objConnection,
    > >
    > > Set rs = objConnection.Execute( sql )
    > > objConnection.Close
    > >
    > > rs.Close
    > > Set rs = Nothing
    > > ----------------------------------
    > > I was getting another error, but the advice was to allow IUSR to have
    > proper
    > > permissions,. which I did. Now, i get this error:
    > >
    > > Microsoft VBScript compilation (0x800A03EA)
    > > Syntax error
    > > /grace/shapethankyou.asp, line 152, column 30
    > > rs.Open strSQL, objConnection,
    > > -----------------------------^
    > >
    > >
    > >
    > >
    > >
    >
    >

    middletree Guest

  5. #5

    Default Re: syntax error

    thanks for clarifying


    "Bob Barrows" <reb_01501> wrote in message
    news:OfTLXC7cDHA.3448TK2MSFTNGP11.phx.gbl...
    > Ray at <%=sLocation%> wrote:
    > > And replace it with
    > > objConnection.Execute strSQL
    >
    > To be completely correct, I would recommend this:
    > objConnection.Execute strSQL,,129
    >
    >

    middletree Guest

  6. #6

    Default Syntax error

    I am a newbie. What EXACTLY do these error messages mean so I can know where
    to start to fix the problem? 'Syntax error (missing operator) in query
    expression...' '....OWNERACCESS OPTION' And I have a general question. Why
    does it take the MM site so long to load? Maizie

    maizie Guest

  7. #7

    Default Re: Syntax error

    Can't tell what the problem is without seeing any of the offending code.
    paross1 Guest

  8. #8

    Default Re: Syntax error

    Two tables, one with company names and contacts related to another table with
    states. They are both part of a master page that lists internships with links
    to PDFs with more info and links to company which drills down to a detail page.
    Everything on the page works except the drilldown to the company detail. Hope
    it makes sense. SELECT internships.ID, internships.company,
    internships.contact_name, internships.contact_title, internships.contact_phone,
    internships.contact_fax, internships.contact_email,
    internships.contact_address, internships.contact_city, internships.contact_zip,
    internships.contact_web, contact_state.contact_state_ID,
    contact_state.contact_state 21 : FROM internships, contact_state 22 : WHERE ID
    = #URL.recordID# 23 : AND internships.contact_state_ID =
    contact_state.contact_state_ID 24 : ORDER BY internships.company

    maizie Guest

  9. #9

    Default Re: Syntax error

    So sorry for the bother. I just found the problem. Another newbie mistake. I apologize for taking your time.

    Maizie
    maizie Guest

  10. #10

    Default Syntax Error

    I am attempting to draw records based on street name and number information but
    cannot seem to get the syntax of the query correct. The error is; ODBC Error
    Code = 37000 (Syntax error or access violation) [Microsoft][ODBC Microsoft
    Access Driver] Syntax error (missing operator) in query expression
    'Street_Number = 1000 and StreetNm = CENTRE LINE'. The error occurred while
    processing an element with a general identifier of (CFQUERY), occupying
    doent position (28:2) to (28:66). The query is; <cfquery
    name='ClientQuery' datasource='CountyGIS' dbtype='odbc'> SELECT * FROM
    Recycle Where Street_Number = #Street_Number# and StreetNm = #StreetNm#
    </cfquery> The StreetNm (street name) is drawn from the DB, passed along to
    the next page where the user manually puts in their Street_Number (street
    number) which then should return matching record(s) from the DB. The error
    shows the correct street name and number...but that is as far as it goes.
    Thanks in advance!

    Christo Guest

  11. #11

    Default Re: Syntax Error

    Since #StreetNm# is text, it should be enclosed within single quotes as in and
    StreetNm = '#StreetNm#'. Also, if Street_Number is also a text/char/varchar
    column in the database, #Street_Number# would also be enclosed in quotes as
    well.

    Phil



    paross1 Guest

  12. #12

    Default Syntax Error

    Hi guys..

    When I try and run the following code it says that there is a missing
    operator..

    SELECT
    curr.portfolio_code,
    curr.date,
    (curr.gross_index-mo1.gross_index)/mo1.gross_index AS 1MONTH_RETURN,
    (curr.gross_index-mo1.gross_index)/mo1.gross_index AS 3MONTH_RETURN
    FROM portfolio_performance AS curr
    LEFT OUTER JOIN portfolio_performance AS mo1
    ON curr.date =
    dateserial(year(dateadd('d',-1,dateserial(Year([mo1].date),
    MONTH([mo1].date)+2, 1))),
    month(dateadd('d',-1,dateserial(Year([mo1].date), MONTH([mo1].date)+2,
    1))),day(dateadd('d',-1,dateserial(Year([mo1].date),MONTH([mo1].date)+2,
    1))))
    LEFT OUTER JOIN portfolio_performance AS mo3
    ON curr.date =
    dateserial(year(dateadd('d',-1,dateserial(Year([mo3].date),
    MONTH([mo3].date)+4, 1))),
    month(dateadd('d',-1,dateserial(Year([mo3].date), MONTH([mo3].date)+4,
    1))),day(dateadd('d',-1,dateserial(Year([mo3].date),MONTH([mo3].date)+4,
    1))))
    ;

    However, when I run the same code, minus the second left outer join it
    works perfectly..

    SELECT
    curr.portfolio_code,
    curr.date,
    (curr.gross_index-mo1.gross_index)/mo1.gross_index AS 1MONTH_RETURN
    FROM portfolio_performance AS curr
    LEFT OUTER JOIN portfolio_performance AS mo1
    ON curr.date =
    dateserial(year(dateadd('d',-1,dateserial(Year([mo1].date),
    MONTH([mo1].date)+2, 1))),
    month(dateadd('d',-1,dateserial(Year([mo1].date), MONTH([mo1].date)+2,
    1))),day(dateadd('d',-1,dateserial(Year([mo1].date),MONTH([mo1].date)+2,
    1))));

    Any help would be appreciated.. im sure its only something minor!

    jared.pohl@gmail.com Guest

Similar Threads

  1. Replies: 6
    Last Post: September 2nd, 01:22 PM
  2. Syntax error?
    By Joneleth in forum MySQL
    Replies: 2
    Last Post: February 15th, 04:46 PM
  3. error : syntax error at or near $1 for over select rows
    By vinita bansal in forum PostgreSQL / PGSQL
    Replies: 1
    Last Post: December 27th, 06:51 PM
  4. syntax error ???
    By Ben in forum PHP Development
    Replies: 1
    Last Post: September 30th, 10:31 PM
  5. SQL Syntax Error
    By Frank Py in forum ASP Database
    Replies: 2
    Last Post: July 11th, 07:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139