Ask a Question related to ASP Database, Design and Development.
-
JW #1
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
-
#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... -
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... -
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... -
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.... -
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... -
Bob Barrows #2
Re: SQL seems reported as wrong.
JW wrote:
<snip>> 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!What does this look like after it's response.written? This is not helpful at> =====================
> (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) & "));" -------------------------------
>
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
-
JW #3
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...at> 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>> What does this look like after it's response.written? This is not helpful> > =====================
> > (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) & "));" -------------------------------
> >not> all. We need to see the actual query that's being sent to the database,If> 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]).> 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
-
Aaron Bertrand [MVP] #4
Re: SQL seems reported as wrong.
> strsql = "SELECT tblZones.PostCode, tblZones.Area FROM tblZones WHERE
Why are you sending CHR(34)? Send ' not the ASCII conversion of "> (((tblZones.PostCode)=" & Chr(34) & txtRiskPostCodePart & Chr(34) & "));"
Aaron Bertrand [MVP] Guest



Reply With Quote

