Solved

Error Incorrect syntax near the keyword 'outer'.

Posted on 2006-11-13
10
1,006 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

636 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