Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 > VBScript - XML Streams.........

Status
Not open for further replies.

ballsup

Technical User
Jul 1, 2002
1
US
I have the following VB6 code i am trying to convert to VBScript but i am having problems with the XML stream, can any pass over any ideas. Heres the origional VB6 Code followed by my conversion so far...:

Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub cmdGo_Click()

Dim rs As New ADODB.Recordset
Dim stm As New ADODB.Stream
Dim xml As New MSXML.XMLHTTPRequest

Const WEBHOST = "
' Show Hourglass:
Screen.MousePointer = vbHourglass

' Open the recordset:
rs.CursorLocation = adUseClient
rs.Open WEBHOST & "/titlesrecordsetxml.asp"

' Make some mods (an update, a delete, and an insert):

' Update:
'rs.Fields("Title") = rs.Fields("Title") & "1"
'rs.Update

' Delete:
'rs.MoveNext
'rs.Delete

' Insert:
rs.AddNew
rs.Fields("job_id") = "4"
rs.Fields("URL") = " rs.Fields("Status") = "0"
rs.Update

' Send the Recordset back to the server:
rs.save stm, adPersistXML
xml.Open "POST", WEBHOST & "/roundtrip.asp", False
Dim szXML As String
szXML = stm.ReadText
xml.send szXML

' Clear Hourglass:
Screen.MousePointer = vbNormal

' Bring up the HTML file in a browser:administrator
ShellExecute Me.hwnd, "open", WEBHOST & "/titlesrecordsetxml.asp", "", CurDir$, 1&

End Sub

----------------------------------------------------

<SCRIPT LANGUAGE=&quot;VBScript&quot;>

Dim rs,stm,xml,szXML
Set rs = CreateObject (&quot;ADODB.Recordset&quot;)
Set stm = CreateObject (&quot;ADODB.Stream&quot;)
Set xml = CreateObject (&quot;Microsoft.XmlHttp&quot;)

rs.CursorLocation = 3
rs.Open &quot;
rs.AddNew
rs.Fields(&quot;job_id&quot;) = &quot;9&quot;
rs.Fields(&quot;URL&quot;) = &quot;rs.Fields(&quot;Status&quot;) = &quot;0&quot;
rs.Update
rs.save stm, adPersistXML
xml.Open &quot;POST&quot;, &quot; False

stm.Write stm.ReadText

szXML = stm.ReadText

xml.send szXML

window.open &quot;
</SCRIPT>
 
What kind of error are you getting, if any?

The first thing I notice is your VBS includes an undefined constant.
rs.save stm, adPersistXML
should be
rs.save stm, 1

Also, I'm thinking this line of code doesnt belong.
stm.Write stm.ReadText
or if it was intentionally included, it should be
stm.WriteText stm.ReadText Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top