473,804 Members | 2,985 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Custo merID = Orders.Customer ID) INNER JOIN (Products INNER
JOIN (OrderLines INNER JOIN StockMovements ON OrderLines.JobN umber =
StockMovements. JobNumber) ON (Products.Produ ctID =
OrderLines.Prod uctID) AND (Products.Produ ctID = OrderLines.Prod uctID))
ON Orders.OrderID = OrderLines.Orde rID"

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 1544
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.Custo merID = Orders.Customer ID) INNER JOIN (Products INNER
JOIN (OrderLines INNER JOIN StockMovements ON OrderLines.JobN umber =
StockMovements. JobNumber) ON (Products.Produ ctID =
OrderLines.Prod uctID) AND (Products.Produ ctID = OrderLines.Prod uctID))
ON Orders.OrderID = OrderLines.Orde rID"

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******** ************@z1 4g2000cwz.googl egroups.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.Custo merID = Orders.Customer ID) INNER JOIN (Products INNER
JOIN (OrderLines INNER JOIN StockMovements ON OrderLines.JobN umber =
StockMovements. JobNumber) ON (Products.Produ ctID =
OrderLines.Prod uctID) AND (Products.Produ ctID = OrderLines.Prod uctID))
ON Orders.OrderID = OrderLines.Orde rID"

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 RemainderStatus BBUK

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

_______________ _______________ _________
strConnection = "driver=
{MySQL};server= xx.xxx.xx.x;uid =xxxxxx;pwd=xxx xx;database=xxx xx"

Set adoDataConn = Server.CreateOb ject("ADODB.Con nection")

adoDataConn.Ope n strConnection
_______________ _______________ __________

I then tried the following in my page:

conn.RemainderS tatusBBUK JobNumber, PONumber

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

set rs = server.createob ject("adodb.rec ordset")
conn.qGetRecord s 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 "adoDataCon n" 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******** ******@TK2MSFTN GP15.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 RemainderStatus BBUK

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

_______________ _______________ _________
strConnection = "driver=
{MySQL};server= xx.xxx.xx.x;uid =xxxxxx;pwd=xxx xx;database=xxx xx"

Set adoDataConn = Server.CreateOb ject("ADODB.Con nection")

adoDataConn.Ope n strConnection
_______________ _______________ __________

I then tried the following in my page:

conn.RemainderS tatusBBUK JobNumber, PONumber

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

set rs = server.createob ject("adodb.rec ordset")
conn.qGetRecord s 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 RemainderStatus BBUK

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

_______________ _______________ _________
strConnection = "driver=
{MySQL};server= xx.xxx.xx.x;uid =xxxxxx;pwd=xxx xx;database=xxx xx"

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=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=p:\ath\t o\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=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & Server.MapPath( "database.m db")
I then tried the following in my page:

conn.RemainderS tatusBBUK 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 RemainderStatus BBUK

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

_______________ _______________ _________
strConnection = "driver=
{MySQL};server= xx.xxx.xx.x;uid =xxxxxx;pwd=xxx xx;database=xxx xx"

Set adoDataConn = Server.CreateOb ject("ADODB.Con nection")

adoDataConn.Ope n 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.RemainderS tatusBBUK JobNumber, PONumber
I doubt ADO connection object has ever had method *RemainderStatu sBBUK*

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

set rs = server.createob ject("adodb.rec ordset")
conn.qGetRecord s 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.RemainderS tatusBBUK JobNumber, PONumber


I doubt ADO connection object has ever had method *RemainderStatu sBBUK*


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.createob ject("adodb.rec ordset")
conn.qGetRecord s 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

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

Similar topics

2
2125
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... &nbsp; ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name&nbsp;&nbsp;&nbsp; dept 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; steve&nbsp;&nbsp; acct
3
1410
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 access database it will not be called back as text.... an example of what I am using is below... all I am after is basically what lots of other major source code sites do and that is diplay the code as text so the user can cut and paste it into...
1
6832
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
1
3216
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 10 minutes) and return to it then the connection hangs. When they try to perform any action that requires a connection to the SQL Server database then the egg-timer mouse pointer displays and the database stops responding. It's as if the...
1
6168
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 glad to have ur answers ASAP. Thanks a lot
3
1518
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 specific mail folder (Outlook 2002) to an MS Access database (Access 2002). However, my problem is the message body, which contains the data I'm interested in, is all placed in the one field. I would like the data contained in the message body to be...
0
1088
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 and is unformatted. I display the text to my user in the listview. The textbox I create logically in the program, and I initialize the correct properties for a normal multiline editor.
3
2092
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, for example, that the Page_Load on the specific page executes before the Page_Load of its MasterPage. Is this right? But what I really want to understand is VARIABLE SCOPE, etc. between the two. For example: Is there a way for me to write code...
1
2807
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 use when querying the database. Right now it is only looking for a match on one of those dropdowns and not all 3. can anyone help? Here is the code: <form BOTID="0" METHOD="POST" action="businessforsale_interface/Results/test3.asp">
1
2362
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 DNS name is "cati", the names are specified in the "Last_names" field, and the categories are in the "categories" field. l want the results sorted in alphabetic order by last name. However, the results appear to be in a totally random,...
0
10569
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10325
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10315
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.