Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Not passing spaces to output

Posted on 2006-11-10
15
Medium Priority
?
283 Views
Last Modified: 2012-05-05
Ok I have one page passing data to another then running a script:

Page1:
<%
ordno= Request.QueryString("ordno")
lbl= Request.QueryString("lbl")
strSQL = "SELECT * FROM labels WHERE sf_ord ='" & ordno & "'"
set rs = Conn.Execute(strSQL)
strSQL1 = "SELECT * FROM sfordfil_sql WHERE ord_no = '" & ordno & "'"
set rs1 = Conn.Execute(strSQL1)%>

<table cellpadding='0' cellspacing='0' width='331' bgcolor='#FFFF00' height='212'><tr><td height='60' valign='top'><p align='center'><font size='5'>WARNING<br>Shop Floor Number<br>
<%=rs("sf_ord")%><br></font></td><tr><td height='77' valign='top'>This Label has been printed <%=rs("zn_4")%> time in Zone 4.<p>Last Printer on <%=rs("zn_4dt")%>. </td></tr><tr><td height='80' width='331'>
<form method="post" action="code.asp">
<div ><p align="center">Username: <input type="text" name="username" size="15"><br>
                        <input type=hidden name=ordno value="<%=rs1("ord_no")%>">
                        <input type=hidden name=lbl value="<%=lbl%>">
            Password: <input type="password" name="password" size="15"><align="center"><br>
      <input type="submit" value="Log In" name="button"></form></tr>
</td></tr></table>

(data come into this page: ordno='    0675', lbl=2)

Page 2:
<%'CONNECTION
Dim sUserName : sUserName = Request.Form("userName")
Dim sUserPwd : sUserPwd = Request.Form("password")
Session("userID") = Request.Form("userName")
Session("Password") = Request.Form("password")
ordno= Request.form("ordno")
lbl= Request.form("lbl")
%>
<%'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")
if len(trim(sUserName&""))>0 AND len(trim(sUserPwd&""))>0 then
  strSQL2 = "SELECT * FROM lbl_users where userID='" & replace(sUserName, "'", "''") & "' AND Password='" & replace(sUserPwd, "'", "''") & "'"
  set rs2 = Conn.Execute(strSQL2)
  if not rs2.EOF then
  Session("LoggedIn") = True
  Session("Name") = Rs2("f_name")

dim RS, strSQL, ordno, strSQL1, rs1

strSQL = "SELECT * FROM labels WHERE sf_ord = '" & ordno & "'"
set rs = Conn.Execute(strSQL)
strSQL1 = "SELECT * FROM sfordfil_sql WHERE ord_no = '" & ordno & "'"
set rs1 = Conn.Execute(strSQL1)%>
<html>
<head>
<title>Print Shop Order</title>
</head>
<SCRIPT LANGUAGE="vbScript">
Dim OkToClose
Sub Print()
     'Create the ASPPrinter object
     Set Prn = CreateObject("ASPPrinterCOM.ASPPrinter")
       Prn.Key="AECDBE9A1422311150DDF89BAC5C53E0F837DB633431CE22FB47513CAE0D31889AB9FD2C47AB024204C"
     ordno = <%=ordno%>
     lbl = <%=lbl%>
     URL="http://tmi-server:8075/z4/" & lbl & "/LBL2.asp?ordno=" & ordno          
       Prn.PrintHTMLDocument url
     Set Prn=Nothing

     OkToClose = false

     Call window.setTimeout("OkToClose = true", 10000)

     MsgBox "Print Completed Successfully!",,"ASP Printer COM"
     Call CloseWindow()
End Sub

Sub CloseWindow()
     If (OkToClose) Then
          Call window.close()
     Else
          Call window.setTimeout("CloseWindow()", 1000)
     End If
End Sub
</SCRIPT>
<body>
<Object ID="ASPPrinter"  
 CLASSID="CLSID:48CB850F-41FF-4EE6-B87D-FB9EC26D193F"  
 CODEBASE="../Z1/ASPPrinter.CAB#version=2,1,0,0">  
 </Object>
<table cellpadding='0' cellspacing='0' width='331' bgcolor='#FFFF00' height='156'><tr><td height='60' valign='top'><p align='center'>
      <font size="5">Printing<br>Shop Floor Number<br>
<%=rs("sf_ord")%></font></td></tr><tr><td height='57' valign='top'>This Label has been printed <%=rs("zn_4")%> time in Zone 4.<p>Last Printer on <%=rs("zn_4dt")%>. </td></tr><tr>
      <td height='19' width='331'>
            <p align='center'>
          <input type='button' value='Print' name='b2' onclick= 'Print()'></p></td></tr></table>
<% Else%>
<%Response.Redirect "warn.asp?ordno=" & ordno & ""%>
<% End If%>
<% End If%>
</body>
</html>
<%'CLOSE
conn.close
set conn = nothing%>

Now what I am seeing is when it runs:
     URL="http://tmi-server:8075/z4/" & lbl & "/LBL2.asp?ordno=" & ordno          
output is:      URL="http://tmi-server:8075/z4/2/LBL2.asp?ordno=6075
What I need is for it to bring the spaces or edit the thrid page.

Page 3:
<%'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, rs2, strSQL3, rs3, strSQL4, rs4, znToAdd, strSQL5, srl
dia = Date()
ordno= Request.QueryString("ordno")
  strSQL = "SELECT * FROM sfordfil_sql where ltrim(ord_no) = " & ordno & ""
  set rs = Conn.Execute(strSQL)
  strSQL1 = "SELECT * FROM labels WHERE sf_ord = " & ordno & ""
  set rs1 = Conn.Execute(strSQL1)
  znToAdd = RS1("zn_4") + 1
  strSQL2 = "SELECT item_no, ltrim(rtrim(user_def_fld_1)) as user_def_fld_1, ltrim(rtrim(user_def_fld_5)) as user_def_fld_5, ltrim(rtrim(user_def_fld_4)) as user_def_fld_4 FROM imitmidx_sql WHERE item_no = '" & rs("item_no") & "'"
  set rs2 = Conn.Execute(strSQL2)
  strSQL3 = "SELECT ltrim(rtrim(ser_lot_no)) as ser_lot_no FROM imlsmst_sql WHERE orig_ord_no = '" & ordno & "' ORDER BY eff_dt DESC"
  set rs3 = Conn.Execute(strSQL3)
srl = "rs3('ser_lot_no')"
  strSQL4 = "update labels set mdl_n = '" & rs("item_no") & "', sn_1 = '" & rs3("ser_lot_no") & "' , status = 4, fnh_dt = '" & rs("compl_dt") & "', mdl_detail = '" & rs2("user_def_fld_1") & "' where sf_ord = " & ordno & ""
  conn.execute(strSQL4)
  strSQL5 = "update labels set mdl_detail = '" & rs2("user_def_fld_1") & "', status = 4, zn_4 = "&znToAdd&", zn_4dt = '"&NOW()&"' where sf_ord = " & ordno & ""
  conn.execute(strSQL5)%>

When I manualy add the spaces it works but if it has no spaces it errors.
0
Comment
Question by:kwitcom
  • 9
  • 6
15 Comments
 
LVL 20

Expert Comment

by:jitganguly
ID: 17914447
The HTML space character is &nbsp;. Have you tried that ?
0
 

Author Comment

by:kwitcom
ID: 17914459
I need it in the Data that comes from SQL need it to pass to each page.
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 17914466
Sorry. Which SQL is that and whats your database ?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 20

Expert Comment

by:jitganguly
ID: 17914493
In SQLServer you can use SPACE(n) e.g.

Select space(5),*,aaa from mytable
0
 

Author Comment

by:kwitcom
ID: 17914604
here is the problem the table has spaces in front of the order numbers, Can't change that.

I am do lookups based on the information but it does not find the recode because of the spaces.
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 17914626
If the table has space use Trim and I guess you are already using that.  Have you tried

Ltrim(Rtrim(order_no)))

0
 
LVL 20

Expert Comment

by:jitganguly
ID: 17914642
You should use trim in both sides.Are you talking about this query ?

"SELECT * FROM sfordfil_sql WHERE Ltrim(RTrim(ord_no)) = '" & Trim(ordno) & "'"
0
 

Author Comment

by:kwitcom
ID: 17914932
That is more what I am looking for let me try that.
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 17914949
I would suggest to trim it while you got it on the first page

<input type=hidden name=ordno value="<%=Trim(rs1("ord_no"))%>">

And in subsequent SQLs use SQL Ltrim(Rtrim(order_no))
0
 

Author Comment

by:kwitcom
ID: 17915205
OK, now i get the following error:
Microsoft OLE DB Provider for SQL Server error '80040e14'
Line 1: Incorrect syntax near '('.
/z4/warn.asp, line 12

Code:
strSQL1 = "SELECT * FROM sfordfil_sql Ltrim(RTrim(ord_no)) = '" & Trim(ordno) & "'"
set rs1 = Conn.Execute(strSQL1)%>

What do i need to chage to fix this?
0
 

Author Comment

by:kwitcom
ID: 17915211
never mind
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 17915232
You can use same Ltrim(Rtrim combination in VBScript also
0
 

Author Comment

by:kwitcom
ID: 17915281
Error:
error '80020009'
/z4/2/lbl2.asp, line 15

Code:
ordno= Request.QueryString("ordno")

  strSQL = "SELECT * FROM sfordfil_sql WHERE Ltrim(RTrim(ord_no)) = '" & Trim(ordno) & "'"
  set rs = Conn.Execute(strSQL)

  strSQL2 = "SELECT item_no, ltrim(rtrim(user_def_fld_1)) as user_def_fld_1, ltrim(rtrim(user_def_fld_5)) as user_def_fld_5, ltrim(rtrim(user_def_fld_4)) as user_def_fld_4 FROM imitmidx_sql WHERE item_no = '" & rs("item_no") & "'"
  set rs2 = Conn.Execute(strSQL2)

Error is somewhere in: strSQL2

This URl does not work:
http://tmi-server:8095/z4/2/lbl2.asp?ordno=6091

This URL works:
http://tmi-server:8095/z4/2/lbl2.asp?ordno=%20%20%20%206091

Something in the trim is not right in strSQL I think.
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 17915417
Can you just do a Response.write of both SQLs and paste it here
0
 
LVL 20

Accepted Solution

by:
jitganguly earned 2000 total points
ID: 17915444
May be  rs("item_no")  is null or zero. Try some debugging

strSQL = "SELECT * FROM sfordfil_sql WHERE Ltrim(RTrim(ord_no)) = '" & Trim(ordno) & "'"
set rs = Conn.Execute(strSQL)

'Added here
If not rs.eof then
  strSQL2 = "SELECT item_no, ltrim(rtrim(user_def_fld_1)) as user_def_fld_1, ltrim(rtrim(user_def_fld_5)) as user_def_fld_5, ltrim(rtrim(user_def_fld_4)) as user_def_fld_4 FROM imitmidx_sql WHERE item_no = '" & rs("item_no") & "'"
  set rs2 = Conn.Execute(strSQL2)
end if



0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

782 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