Line 1: Incorrect syntax near '<'.

Discussion in 'Javascript' started by iporter, Dec 22, 2006.

  1. iporter

    iporter Guest

    In the following code, the two Response.Write statements output exactly
    the same - I can copy and paste both into Query Analyzer, and run them
    fine. However, if I comment out line 3, the assignment of "SELECT
    T..." to the variable query, the last line produces the error:

    Line 1: Incorrect syntax near '<'.

    Many thanks in advance for any explanation - the problem is tearing my
    hair out!!
    Iain

    CODE:
    ---------------
    var query = unprocessedRuleHTML.substring(ruleIndex.length,
    (unprocessedRuleHTML.length - "</DIV>".length));

    Response.Write("**" + query + "**<br /><br />");

    query = "SELECT TOP 5 CI_MI.CI_ID, MI_ID, MI.url, CI.content, title,
    AccessibilityTitle, MI.LongTitle, extension FROM ContentItems CI LEFT
    JOIN CI_MI ON CI_MI.CI_ID = CI.ID LEFT JOIN MenuItems MI ON CI_MI.MI_ID
    = MI.ID LEFT JOIN CF_CI ON CI.ID = CF_CI.CI_ID LEFT JOIN ContentFormats
    CF ON CF_CI.CF_ID = CF.ID LEFT JOIN CI_T ON CI.ID = CI_T.CI_ID LEFT
    JOIN Tags T ON CI_T.T_ID = T.ID WHERE tag = 'crop protection'";

    Response.Write("**" + query + "**<br /><br />");

    var tempData = executeRS(query);
     
    iporter, Dec 22, 2006
    #1
    1. Advertising

  2. iporter

    iporter Guest

    Followup - I thin it's something to do with having the single quote
    marks in the string. If I replace just the last part of the string,
    the 'crop protection' (including single quote marks), then it works
    (see code below).

    I tried storing these as escaped (thus \'crop protection\'), but it
    gave me the error message: Line 1: Incorrect syntax near '\'.

    Thanks again,
    Iain

    CODE
    ---------------
    query2 += query.substring(0, 386) + "'crop protection'";
    var tempData = executeRS(query);

    iporter wrote:

    > In the following code, the two Response.Write statements output exactly
    > the same - I can copy and paste both into Query Analyzer, and run them
    > fine. However, if I comment out line 3, the assignment of "SELECT
    > T..." to the variable query, the last line produces the error:
    >
    > Line 1: Incorrect syntax near '<'.
    >
    > Many thanks in advance for any explanation - the problem is tearing my
    > hair out!!
    > Iain
    >
    > CODE:
    > ---------------
    > var query = unprocessedRuleHTML.substring(ruleIndex.length,
    > (unprocessedRuleHTML.length - "</DIV>".length));
    >
    > Response.Write("**" + query + "**<br /><br />");
    >
    > query = "SELECT TOP 5 CI_MI.CI_ID, MI_ID, MI.url, CI.content, title,
    > AccessibilityTitle, MI.LongTitle, extension FROM ContentItems CI LEFT
    > JOIN CI_MI ON CI_MI.CI_ID = CI.ID LEFT JOIN MenuItems MI ON CI_MI.MI_ID
    > = MI.ID LEFT JOIN CF_CI ON CI.ID = CF_CI.CI_ID LEFT JOIN ContentFormats
    > CF ON CF_CI.CF_ID = CF.ID LEFT JOIN CI_T ON CI.ID = CI_T.CI_ID LEFT
    > JOIN Tags T ON CI_T.T_ID = T.ID WHERE tag = 'crop protection'";
    >
    > Response.Write("**" + query + "**<br /><br />");
    >
    > var tempData = executeRS(query);
     
    iporter, Dec 22, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    10,774
    Patrick.O.Ige
    Oct 11, 2004
  2. Patrick Olurotimi Ige
    Replies:
    4
    Views:
    7,073
    Patrick Olurotimi Ige
    Mar 18, 2005
  3. JMUApache
    Replies:
    2
    Views:
    3,342
    Brendan Reynolds
    Sep 4, 2005
  4. David

    Incorrect syntax near 'int'

    David, Apr 6, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    2,512
    David
    Apr 7, 2006
  5. levis
    Replies:
    0
    Views:
    3,545
    levis
    Sep 20, 2006
Loading...

Share This Page