Solved

Error Incorrect syntax near the keyword 'outer'.

Posted on 2006-11-13
10
999 Views
Last Modified: 2006-11-18
Error:
Microsoft OLE DB Provider for SQL Server error '80040e14'
Incorrect syntax near the keyword 'outer'.
/z4/1/lbl2.asp, line 27

Code:
<%'CONNECTION
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=SQLOLEDB; Data Source=localhost; Initial Catalog=001; User ID=; Password="
Set ObjRs = Server.CreateObject("ADODB.Recordset")
'DECLARATIONS
dim dia, strSQL, rs, strSQL1, rs1, ordno, strSQL2, strSQL3, rs3, strSQL4, rs4, znToAdd, strSQL5, srl
dia = Date()
ordno= Request.QueryString("ordno")
  strSQL = "Select * from (SELECT " &_
                  "ltrim(rtrim(s.ord_no)) as order_no," &_
                  "ltrim(rtrim(i.user_def_fld_1)) as eng_no, " &_
                  "ltrim(rtrim(i.user_def_fld_2)) as export2," &_
                  "ltrim(rtrim(i.user_def_fld_3)) as label," &_
                  "ltrim(rtrim(i.user_def_fld_4)) as cust," &_
                  "ltrim(rtrim(i.user_def_fld_5)) as cust_no " &_
                  "FROM sfordfil_sql s " &_
                  "left outer join imitmidx_sql i " &_
                  "on s.item_no = i.item_no) as tab1 " &_
                  "INNER JOIN " &_
                  "(SELECT ltrim(rtrim(ser_lot_no)) as ser_no, " &_
                  "l.* FROM labels l" &_
                  "right outer join imlsmst_sql q " &_
                  "on l.sf_ord = q.orig_ord_no) as tab2" &_
                  "ON tab1.order_no = tab2.sf_ord" &_
                  "where tab1.order_no = '& ordno & '"
  set rs = Conn.Execute(strSQL)                                                                       <--- This is Line 27
  znToAdd = RS("zn_4") + 1
%>

When I run in SQL Profiler it works.
0
Comment
Question by:kwitcom
  • 6
  • 4
10 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 17929748
Hi kwitcom,

               "l.* FROM labels l" &_
               "right outer join imlsmst_sql q " &_

These two lines become l.* FROM labels lright outer join ... you need a space in there

               "l.* FROM labels l " &_
               "right outer join imlsmst_sql q " &_


Tim Cottee
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 17929752
kwitcom,

>             "on l.sf_ord = q.orig_ord_no) as tab2" &_
>                "ON tab1.order_no = tab2.sf_ord" &_
>                "where tab1.order_no = '& ordno & '"

You will also need some here as well otherwise you will get other errors!

Tim
0
 

Author Comment

by:kwitcom
ID: 17929902
Now I get:
error '80020009'
/z4/1/lbl2.asp, line 28

Line is 28 is:
  znToAdd = RS("zn_4") + 1
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 43

Expert Comment

by:TimCottee
ID: 17929944
TimCottee,

zn_4 doesn't appear to be a field name in the returned recordset. What table is it in?

Tim
0
 

Author Comment

by:kwitcom
ID: 17929993
labels and it does come back in SQl Profiler.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 17930037
kwitcom,

Ok, it could be that although it is there, it either conflicts with another field name or for some reason gets a different identifier. This does sometimes happen with complex queries. Could you first of all try a simple test to show all the field names you get out of the query:

For intField = 0 to rs.fields.count - 1
    Response.write (intfield & " : " & rs(intfield).name & " = " & rs(intfield).value & "<br />")
next

This will show you the field index, name and current value (assuming there are records returned) for the first record. Given that we can work out whether it has changed the fieldname or not.

Tim
0
 

Author Comment

by:kwitcom
ID: 17930130
Error:
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/z4/1/lbl2.asp, line 29

Code:
<%'CONNECTION
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=SQLOLEDB; Data Source=localhost; Initial Catalog=001; User ID=; Password="
Set ObjRs = Server.CreateObject("ADODB.Recordset")

'DECLARATIONS
dim dia, strSQL, rs, strSQL1, rs1, ordno, strSQL2, strSQL3, rs3, strSQL4, rs4, znToAdd, strSQL5, srl
dia = Date()
ordno= Request.QueryString("ordno")
  strSQL = "Select * from (SELECT " &_
                  "ltrim(rtrim(s.ord_no)) as order_no, " &_
                  "ltrim(rtrim(i.user_def_fld_1)) as eng_no, " &_
                  "ltrim(rtrim(i.user_def_fld_2)) as export2, " &_
                  "ltrim(rtrim(i.user_def_fld_3)) as label, " &_
                  "ltrim(rtrim(i.user_def_fld_4)) as cust, " &_
                  "ltrim(rtrim(i.user_def_fld_5)) as cust_no " &_
                  "FROM sfordfil_sql s " &_
                  "left outer join imitmidx_sql i " &_
                  "on s.item_no = i.item_no) as tab1 " &_
                  "INNER JOIN " &_
                  "(SELECT ltrim(rtrim(ser_lot_no)) as ser_no, " &_
                  "l.* FROM labels l " &_
                  "right outer join imlsmst_sql q " &_
                  "on l.sf_ord = q.orig_ord_no) as tab2 " &_
                  "ON tab1.order_no = tab2.sf_ord " &_
                  "where tab1.order_no = '& ordno & '"
  set rs = Conn.Execute(strSQL)
For intField = 0 to rs.fields.count - 1
    Response.write (intfield & " : " & rs(intfield).name & " = " & rs(intfield).value & "<br />")                                    <---Line with Error
next
  znToAdd = RS("zn_4") + 1
%>
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 17930172
kwitcom,

Ok, so that is implying that we don't get any records back from the query. If we did then there would be some field names shown. This is likely to be the cause of the previous error even though it didn't actually say so. If you are getting records returned in query analyzer, but not with the query here then there has to be something different that is causing this.

What is the format of the ordno variable? Is it numeric or a character string? If it is a string then that could be the problem, in fact there it is. Just as I was looking at it again I noticed that you haven't quoted that last line correctly, it should be:

               "where tab1.order_no = '" & ordno & "'"

Otherwise it was trying to find records where tabl1.order_no = '& ordno &' which is obviously never going to work!

Tim
0
 

Author Comment

by:kwitcom
ID: 17930191
Worked:
0 : order_no = 6091
1 : eng_no = 1002-PR-P-MA-ST-53
2 : export2 = 1
3 : label = 2
4 : cust = GCS
5 : cust_no =
6 : ser_no = 06450268
7 : sf_ord = 6091
8 : zn_1 = 1
9 : zn_1dt = 11/9/2006 7:01:02 AM
10 : zn_2 = 0
11 : zn_2dt =
12 : zn_3 = 0
13 : zn_3dt =
14 : zn_4 = 2
15 : zn_4dt = 11/10/2006 11:07:40 AM
16 : fnh_dt = 11/10/2006
17 : mdl_n = 10202-PR
18 : sn_1 = 06450268
19 : mdl_detail = 1002-PR-P-MA-ST-53
20 : status = 4
21 : doc = 1
22 : doc_dt = 11/9/2006 7:01:04 AM
23 : doc_prt_by =
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 17930221
kwitcom,

So now you can go back and use the rs(zn_4)+1 line as you were going to and hopefully you should get it working now. It looks like it was that incorrectly quoted line that was throwing it out.

Tim
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FileUp - Classic ASP 5 19
Connecting to multiple databases to create a Dashboard 5 47
Html fieldset fix its height and width 4 27
VBScript on Html 15 47
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question