Posted on 2006-03-20
Last Modified: 2006-11-18

I have a vbscript below that I need to run on the client then post to another page using XMLHttp, can you please help me figure out the XMLHttp part. I need to figure out what I need to add to this page and what needs to be on the sequent page to then insert the data into the DB.



<!--#include file="dstlstLabel.asp"-->
<!--#include file="../Include/InitSysData.asp"-->
<!--#include file="../Include/C850_Format_date_V1.asp"-->
Action = Request("Action")
Dim prmReturn(0)
Dim prmValue(9)
Dim prmWhere(8)
prmWhere(0)="DEST_ID NOT LIKE '*******%*'"
Dim prmOrder(4)
prmOrder(0)="DEST_ID ASC"
prmOrder(1)="DEST_LOC_DESC ASC"
Dim HCPR_STATUS                
Dim rsGCTD
Dim Csik_table_id
Dim Csik_code
Dim Csik_Rcpt_Rtv_Id
' set up and get switch from GCVMNT with HCSW for CLIENTPRNT
Csik_Table_id = "HCSW"
Csik_code = "CLIENTPRNT"
sql = "SELECT"
sql = sql & " code_status"
sql = sql & " FROM GCTD"
sql = sql & " WHERE table_id = '" & CSIK_TABLE_ID & "'"
sql = sql & " and code = '" & csik_code & "'"
ControlDBConnection = Application("ControlDBConnection")
Call Open_ADO_Connection(Conn, ControlDBConnection)
Set RS = Server.CreateObject("ADODB.RecordSet")
RS.Open sql, Conn, adOpenForwardOnly, adLockReadOnly
If Not (rs.EOF) Then
    HCPR_STATUS = CobraStr(rs("CODE_STATUS"))
    Call csiDestroyRecordSet(rs)
End If
' test switch from above and if "A" then run script and insert printers into prnt table
if HCPR_STATUS = "A" then
  ' set up to get next client id from value of Oracle sequence csi_seq_client
  dim rs2
  dim client
  sql = "select csi_seq_client.nextval from dual"
  Set RS2 = Server.CreateObject("ADODB.RecordSet")
  RS2.Open sql, Conn, adOpenForwardOnly, adLockReadOnly
  client = CobraStr(rs2(0))
   <script language="vbscript">
  Option Explicit
  If <%=HCPR_STATUS%>="A" Then
  Dim strComputer, objWMIService, colInstalledPrinters, objPrinter
  Dim objNetwork
  Dim strPrinters
  Set objNetwork = CreateObject("WScript.Network")
  'Get the printer collection
  strComputer = "."
  Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")
  strPrinters = strPrinters & "<?xml version=""1.0"" standalone=""yes""?>"
  strPrinters = strPrinters & "<InstalledPrinters>"
  For Each objPrinter in colInstalledPrinters
    If(inStr(objPrinter.Name,"\\") > 0) Then
      Conn.execute("insert into hcpr values(" & client & ",'" & objPrinter.Name & _
        "',DECODE(" & objPrinter.Default & "'FALSE',' ','DEFAULT')")
    end if
  End If
  ' insert 2 dummy values into Oracle table HCPR just for testing
  ' Do a "select * from HCPR" in cmbsperfsrv01 demo2 to check
  'Conn.execute("insert into hcpr values(" & client & ",'\\ps02\4e3x','Default')")
  'Conn.execute("insert into hcpr values(" & client & ",'\\ps02\4e4x','')")
  'call getprtr(client)
  Set RS2 = Nothing
  ' CUSTOM CODE - set up sql statement to send to "prompt"
  prmSql="SELECT printer_id, default_flag FROM hcpr"
  prmWhere(0)="session_id = " & client
'  Response.write " pre del"
'  Conn.execute("delete from hcpr where session_id = " & client)
'  Response.write " del done"
  ' STANDARD CODE - set up sql statement to send to "prompt"
end if
<!--#include file="../Include/Prompt.asp"-->
Question by:padgettbrian
    LVL 8

    Expert Comment


    Author Comment

    I also need to pass the value of the variable to the next page. How do you pass this var to the next ASP page?

    client = CobraStr(rs2(0))

    LVL 8

    Accepted Solution

    Pass the "client" value to the client-side script and then include it with the insert:

    Dim myhttp
    datatosend="printers=" & strPrinters & "&client=" & "<% = client %>"
    Set myhttp=CreateObject("Msxml2.XMLHTTP") "POST", "test.asp", false
    myhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    myhttp.send datatosend
    set myhttp = Nothing


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    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…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now