SQL seems reported as wrong.

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default SQL seems reported as wrong.

    Hi, I'm new to asp coding database, but have been working with Web Design
    and MS Access for quite a few years.

    I'm access a db and am useing the following code (1) and all is well. When
    I replace the sql string with the code at (2) I get an "error '80004005'
    Unspecified error /quotes/quote3.asp, line 48 " error message - not very
    useful!

    I've pasted the sql back into a query in access and it workds fine. So I'm
    stumped. Any help would, of course, be appreciated.

    (1) lines that work:
    =====================
    <%
    'initialise objects and variables
    dim conn, strsql, rsuser, strMDBPath
    set conn=server.createobject("ADODB.Connection")
    set rsuser=server.createobject("ADODB.Recordset")
    strMDBpath = Server.MapPath("quote.mdb")

    'direct connection
    conn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & strMDBPath

    strsql = "SELECT tblZones.PostCode, tblZones.Area FROM tblZones WHERE
    (((tblZones.PostCode)=" & Chr(34) & txtRiskPostCodePart & Chr(34) & "));"

    'print the sql out to check it
    response.Write strsql & "<br>"

    rsuser.open strsql,conn,1,2
    'code here to use the data!!

    'close resources used
    rsuser.close
    conn.close

    'clean up
    set rsuser=nothing
    set conn=nothing
    %>
    =====================
    (2) The sql string that causes there error, but appears OK:
    -------------------------------
    strsql = "SELECT tblRatesMatrix.Zone, tblRatesMatrix.C1 FROM tblRatesMatrix
    WHERE (((tblRatesMatrix.Zone)=" & Chr(34) & txtZone & Chr(34) & "));"
    -------------------------------

    Thanks

    Jon
    jon_webb ^at^ yahoo ^dot^ com


    JW Guest

  2. Similar Questions and Discussions

    1. #40491 [Opn->Csd]: similar to reported Bug #8269
      ID: 40491 User updated by: alexander dot weber at vodafone dot com Reported By: alexander dot weber at vodafone dot com...
    2. SelectedIndex Value Reported Incorrectly
      I am writing a User Control that uses 3 DropDownLists. When I attempt to access the SelectedIndex property it incorrectly reports the value selected...
    3. Fireworks reported an I O error.
      Having trouble with Web Photo Album 2.2.6 for Dreamweaver MX2004. It was working up until a few weeks ago. Now I get this error when trying to...
    4. memory size reported by ps
      Hi, Looking at memory usage by processes, I used a ps -efo "args,vsz". I would expect to get the size of the process is real memory+pagingspace....
    5. flaw reported about 10 days ago re windows
      Just prior to recently, The Christian Science Monitor cited that a major flaw in Windows had been reported, from Poland, a flaw in Windows that...
  3. #2

    Default Re: SQL seems reported as wrong.

    JW wrote:
    > Hi, I'm new to asp coding database, but have been working with Web
    > Design and MS Access for quite a few years.
    >
    > I'm access a db and am useing the following code (1) and all is well.
    > When I replace the sql string with the code at (2) I get an "error
    > '80004005' Unspecified error /quotes/quote3.asp, line 48 " error
    > message - not very useful!
    <snip>
    > =====================
    > (2) The sql string that causes there error, but appears OK:
    > -------------------------------
    > strsql = "SELECT tblRatesMatrix.Zone, tblRatesMatrix.C1 FROM
    > tblRatesMatrix WHERE (((tblRatesMatrix.Zone)=" & Chr(34) & txtZone &
    > Chr(34) & "));" -------------------------------
    >
    What does this look like after it's response.written? This is not helpful at
    all. We need to see the actual query that's being sent to the database, not
    the vbscript statement that concatenates some string characters and
    variables and assigns them to another variable.

    My guess:
    "Zone" is an ODBC reserved word ([url]http://www.aspfaq.com/show.asp?id=2080[/url]). If
    you can't change the name of the field, you will need to delimit it with
    brackets [zone] in order to use it in a sql statement passed via ADO.

    HTH,
    Bob Barrows


    Bob Barrows Guest

  4. #3

    Default Re: SQL seems reported as wrong.

    Bob,
    Thanks for the reply.

    The sql becomes, for example:
    strsql =3D "SELECT tblRatesMatrix.Zone, tblRatesMatrix.C1 FROM =
    tblRatesMatrix WHERE (((tblRatesMatrix.Zone)=3D"Z2"));"

    However, you were spot on I changed Zone to txtZone and it worked!

    Thank you

    Jon

    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:uT$t6SQhDHA.884@TK2MSFTNGP12.phx.gbl...
    > JW wrote:
    > > Hi, I'm new to asp coding database, but have been working with Web
    > > Design and MS Access for quite a few years.
    > >
    > > I'm access a db and am useing the following code (1) and all is well.
    > > When I replace the sql string with the code at (2) I get an "error
    > > '80004005' Unspecified error /quotes/quote3.asp, line 48 " error
    > > message - not very useful!
    >
    > <snip>
    > > =====================
    > > (2) The sql string that causes there error, but appears OK:
    > > -------------------------------
    > > strsql = "SELECT tblRatesMatrix.Zone, tblRatesMatrix.C1 FROM
    > > tblRatesMatrix WHERE (((tblRatesMatrix.Zone)=" & Chr(34) & txtZone &
    > > Chr(34) & "));" -------------------------------
    > >
    > What does this look like after it's response.written? This is not helpful
    at
    > all. We need to see the actual query that's being sent to the database,
    not
    > the vbscript statement that concatenates some string characters and
    > variables and assigns them to another variable.
    >
    > My guess:
    > "Zone" is an ODBC reserved word ([url]http://www.aspfaq.com/show.asp?id=2080[/url]).
    If
    > you can't change the name of the field, you will need to delimit it with
    > brackets [zone] in order to use it in a sql statement passed via ADO.
    >
    > HTH,
    > Bob Barrows
    >
    >

    JW Guest

  5. #4

    Default Re: SQL seems reported as wrong.

    > strsql = "SELECT tblZones.PostCode, tblZones.Area FROM tblZones WHERE
    > (((tblZones.PostCode)=" & Chr(34) & txtRiskPostCodePart & Chr(34) & "));"
    Why are you sending CHR(34)? Send ' not the ASCII conversion of "


    Aaron Bertrand [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may 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