473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

MS Access SQL > ASP SQL problem....

Hi,

I have the following code which returns an error when run as part of my
ASP SQL....

strquery = strquery & "FROM (Customers INNER JOIN Orders ON
Customers.CustomerID = Orders.CustomerID) INNER JOIN (Products INNER
JOIN (OrderLines INNER JOIN StockMovements ON OrderLines.JobNumber =
StockMovements.JobNumber) ON (Products.ProductID =
OrderLines.ProductID) AND (Products.ProductID = OrderLines.ProductID))
ON Orders.OrderID = OrderLines.OrderID"

I have copied this direct from MS Access Query SQL. How would I adapt
this code to work in ASP ?
Appreciate your help
David

Jul 22 '05 #1
10 1523
da***@scene-double.co.uk wrote:
Hi,

I have the following code which returns an error
What error?
when run as part of
my ASP SQL....

strquery = strquery & "FROM (Customers INNER JOIN Orders ON
Customers.CustomerID = Orders.CustomerID) INNER JOIN (Products INNER
JOIN (OrderLines INNER JOIN StockMovements ON OrderLines.JobNumber =
StockMovements.JobNumber) ON (Products.ProductID =
OrderLines.ProductID) AND (Products.ProductID = OrderLines.ProductID))
ON Orders.OrderID = OrderLines.OrderID"

I have copied this direct from MS Access Query SQL. How would I adapt
this code to work in ASP ?

The only way to debug a sql statement is to know what it is. Do

Response.Write strquery

to see what your vbscript code has generated. If it is correct you should be
able to copy and paste it from the browser window into the SQL View of an
Access Query Builder and run it without modification (unless wildcards are
involved).

You would be better off executing the saved query directly instead of
dealing with all the dynamic sql nonsense:
http://groups-beta.google.com/group/...d6889?oe=UTF-8

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #2
All those parentheses are causing the SQL interpreter problems. You also
need an ON after each INNER JOIN... you can't say INNER JOIN INNER JOIN ON
ON. Gawd, Access teaches some bad habits. Try this:

FROM Customers c
INNER JOIN Orders o
ON c.CustomerID = o.CustomerID
INNER JOIN OrderLines oL
ON oL.OrderID = oL.OrderID
INNER JOIN Products p
ON oL.ProductID = p.ProductID
INNER JOIN StockMovements s
ON oL.JobNumber = s.JobNumber

--
http://www.aspfaq.com/
(Reverse address to reply.)


<da***@scene-double.co.uk> wrote in message
news:11********************@z14g2000cwz.googlegrou ps.com...
Hi,

I have the following code which returns an error when run as part of my
ASP SQL....

strquery = strquery & "FROM (Customers INNER JOIN Orders ON
Customers.CustomerID = Orders.CustomerID) INNER JOIN (Products INNER
JOIN (OrderLines INNER JOIN StockMovements ON OrderLines.JobNumber =
StockMovements.JobNumber) ON (Products.ProductID =
OrderLines.ProductID) AND (Products.ProductID = OrderLines.ProductID))
ON Orders.OrderID = OrderLines.OrderID"

I have copied this direct from MS Access Query SQL. How would I adapt
this code to work in ASP ?
Appreciate your help
David

Jul 22 '05 #3
Bob,

Great to hear from you again. At least I know I can count on you for
great help.

I tried response.write...not much help really.
It would be much easier for me to run a query which is already saved in
th MS Access Back End and output the results direct into ASP.

My Query is called RemainderStatusBBUK

I already have an include file for the connection to the database:

_______________________________________
strConnection = "driver=
{MySQL};server=xx.xxx.xx.x;uid=xxxxxx;pwd=xxxxx;da tabase=xxxxx"

Set adoDataConn = Server.CreateObject("ADODB.Connection")

adoDataConn.Open strConnection
________________________________________

I then tried the following in my page:

conn.RemainderStatusBBUK JobNumber, PONumber

'''JobNumber & PONumber are two fields in my Query

set rs = server.createobject("adodb.recordset")
conn.qGetRecords parm1,parm2, rs
How do I define Conn or what do I replace it with ?
Thanks
David


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 22 '05 #4
conn is the de facto standard name for a connection object. You called your
connection object "adoDataConn" so you either need to change the definition
or change the references.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"David Gordon" <da***@scene-double.co.uk> wrote in message
news:O8**************@TK2MSFTNGP15.phx.gbl...
Bob,

Great to hear from you again. At least I know I can count on you for
great help.

I tried response.write...not much help really.
It would be much easier for me to run a query which is already saved in
th MS Access Back End and output the results direct into ASP.

My Query is called RemainderStatusBBUK

I already have an include file for the connection to the database:

_______________________________________
strConnection = "driver=
{MySQL};server=xx.xxx.xx.x;uid=xxxxxx;pwd=xxxxx;da tabase=xxxxx"

Set adoDataConn = Server.CreateObject("ADODB.Connection")

adoDataConn.Open strConnection
________________________________________

I then tried the following in my page:

conn.RemainderStatusBBUK JobNumber, PONumber

'''JobNumber & PONumber are two fields in my Query

set rs = server.createobject("adodb.recordset")
conn.qGetRecords parm1,parm2, rs
How do I define Conn or what do I replace it with ?
Thanks
David


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 22 '05 #5
David Gordon wrote:
Bob,

Great to hear from you again. At least I know I can count on you for
great help.

I tried response.write...not much help really.
It should have been, but you seem to be taking the proper course below, so I
won't pursue it.
It would be much easier for me to run a query which is already saved
in th MS Access Back End and output the results direct into ASP.

My Query is called RemainderStatusBBUK

I already have an include file for the connection to the database:

_______________________________________
strConnection = "driver=
{MySQL};server=xx.xxx.xx.x;uid=xxxxxx;pwd=xxxxx;da tabase=xxxxx"

You need to use the native OLE DB Provider for Jet in order to treat saved
queries as stored procedures. Unless your database is protected by workgroup
security (if you don't know what workgroup security is then it isn't) you do
NOT supply a username and password in the connection string or in the open
statement. The string should look like:

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=p:\ath\to\database.mdb"

The path to the database must be supplied as a physical file path. You can
use Server.MapPath to get the correct path if needed:
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("database.mdb")
I then tried the following in my page:

conn.RemainderStatusBBUK JobNumber, PONumber

'''JobNumber & PONumber are two fields in my Query


Fields? They need to be parameters. Go back and reread the link I showed you
in the last message.

Here's another one to look at, as well:
http://groups-beta.google.com/group/...UTF-8&oe=UTF-8

It got truncated, but at least the part where I explained about parameters
is still there.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #6
Aaron [SQL Server MVP] wrote:
All those parentheses are causing the SQL interpreter problems.


I hate it myself, but unfortunately, Jet requires multiple joins to be
nested with parentheses. It makes for very messy, hard-to-read sql, but
without them, Jet barfs. That's why i always recommend the use of the query
builder to build queries involving 3 or more tables.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #7
io
> It would be much easier for me to run a query which is already saved in
th MS Access Back End and output the results direct into ASP.

My Query is called RemainderStatusBBUK

I already have an include file for the connection to the database:

_______________________________________
strConnection = "driver=
{MySQL};server=xx.xxx.xx.x;uid=xxxxxx;pwd=xxxxx;da tabase=xxxxx"

Set adoDataConn = Server.CreateObject("ADODB.Connection")

adoDataConn.Open strConnection
Judging by the connection string you are attempting to connect to MySQL
database, not MS Access.


I then tried the following in my page:

conn.RemainderStatusBBUK JobNumber, PONumber
I doubt ADO connection object has ever had method *RemainderStatusBBUK*

'''JobNumber & PONumber are two fields in my Query

set rs = server.createobject("adodb.recordset")
conn.qGetRecords parm1,parm2, rs
Again, never seen *qGetRecords* as a ADO connection method


How do I define Conn or what do I replace it with ?


You either failed to explain yourself clearly or (the worst case scenario)
do not understand what you do. In either case no one will be able to help
you unless they have a clear picture of what needs to be done. Try not to
get into technicalities straight away, but rather explain the bigger
picture. Are you migrating from MS Access to MySQL with ASP?

Jul 22 '05 #8
io
I then tried the following in my page:

conn.RemainderStatusBBUK JobNumber, PONumber


I doubt ADO connection object has ever had method *RemainderStatusBBUK*


Oh, dear... That's an equivalent to a DAO Database object where all
tables/queries become exposed upon a connection! How could I forget!


'''JobNumber & PONumber are two fields in my Query

set rs = server.createobject("adodb.recordset")
conn.qGetRecords parm1,parm2, rs


Again, never seen *qGetRecords* as a ADO connection method


See comment above

How do I define Conn or what do I replace it with ?


You either failed to explain yourself clearly or (the worst case scenario)
do not understand what you do. In either case no one will be able to help
you unless they have a clear picture of what needs to be done. Try not to
get into technicalities straight away, but rather explain the bigger
picture. Are you migrating from MS Access to MySQL with ASP?

Jul 22 '05 #9
Bob Barrows [MVP] wrote:
Aaron [SQL Server MVP] wrote:
All those parentheses are causing the SQL interpreter problems.


I hate it myself, but unfortunately, Jet requires multiple joins to be
nested with parentheses. It makes for very messy, hard-to-read sql,
but without them, Jet barfs. That's why i always recommend the use of
the query builder to build queries involving 3 or more tables.

Oh Damn. Ignore this. I just realized that to OP was using MySQL, not
Access!
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #10
Bob Barrows [MVP] wrote:
David Gordon wrote:

_______________________________________
strConnection = "driver=
{MySQL};server=xx.xxx.xx.x;uid=xxxxxx;pwd=xxxxx;da tabase=xxxxx"


You need to use the native OLE DB Provider for Jet in order to treat
saved
queries as stored procedures.


Ignore this. I failed to realize that you were using MySQL. i think you
would be better off finding a NySQL group or forum to figure out your
problem. Remember: JetSQL syntax is unlikely to translate well into MySQL
sql syntax, especially if your query utilizes VBA functions.

Bob BArrorw

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve Briley | last post by:
I'm new to Python and I'm trying to do some database work with MS Access, but I can't seem to get around a "datatype mismatch error".&nbsp; Here's an example table that I'm working with... ...
3
by: Wayne... | last post by:
I'm trying to make a sort of source code libary for some customers of commonly used code to save them a bit of time the problem I have is that although I can get the asp code into a field of an...
1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
1
by: Davey | last post by:
I have an MS Access 2003 database that uses a SQL Server 2000 database as it's back-end. The database runs well most of the time but if the users dont use the database for a period of time (approx...
1
by: WUV999U | last post by:
Hi I am fairly new to VBA and want to know how I can convert or I mean parse the XML file and convert to an access database. Please help. I greatly appreciate your time and help. I would be...
3
by: Zman | last post by:
I've recently added form functionality on my website, which runs with the aid of a perl script and sends the results via an email message. I'm currently able to import, or link, data from a...
0
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
3
by: Alex Maghen | last post by:
Hi. I'm a little confused about the code that resides in the code-behind of a MasterPage and the code that resides in the code-behind of the actual pages that USE that MasterPage. I'm noticing,...
1
by: Webstorm | last post by:
Hi, I hope someone can help me sort this out a bit, Im completely lost. Here is the page I am working on: http://www.knzbusinessbrokers.com/default.asp I have 3 search critera that I need to...
1
by: Brit | last post by:
I have an ASP file that retrieves names from an Access database for 4 different categories of membership, which the visitor to the page selects (corporate, institutional, regular, or student). The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.