Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1696
  • Last Modified:

Microsoft VBScript runtime error '800a01a8'Object required: '<LoginDetails>'

I am trying to generate XML file & save it.
I get the following error:
objXML.save(xmlpath) 'Line 79 Microsoft VBScript runtime error '800a01a8'Object required: '<LoginDetails>'
I have attached class file cXMLTextWriter.asp
and below is code with error at line 79.
Thanks in advance for any help given.
<%
Response.Write("<div style='position:absolute;width:677px;height:187px;left:0px;top:288px;font-size:xx-small;overflow:auto;border:1px solid #722F90;' id='DIV99'>")
Response.Write("id='DIV101-Functions<br/>")
Dim default
Select Case Request.Form("strAction")
     Case "Login"
          Response.Write("You clicked 'Login'<p>")
     Case "Read XML"
            FileName = Session("FileName")
            Response.Write("id='DIV99-ReadXML<br/>")
            Response.Write("FileName:" & FileName & "#<br/>")
            Dim designdoc, nodes, n, t, h
Dim nIndex : nIndex = 0
Dim strArray(8)
Set designdoc = Server.CreateObject("Microsoft.XMLDOM") 'read the source file
designdoc.preserveWhiteSpace = True
designdoc.async = False
'designdoc.Load(Server.MapPath("../Template/XML/test.xml"))
'C:\Projects\cams00CsVbDevExp\sqlScriptClassicData\Template\XML\Server.xml
designdoc.Load(Server.MapPath(FileName))
Set nodes = designdoc.documentElement.selectNodes("*")
For Each n in nodes
      'skip  xml comment nodes
      If 9 <> n.nodeType Then
            t=Split( n.Text,chr(10),-1,0)
            For I=0 to UBound(t)
                  h = h & "Line " & I & ": " & t(I) & vbCrLf
                  strArray(nIndex) = t(I)
                  nIndex = nIndex + 1
            Next
            Session("xtProvider") = strArray(0)
            Session("xtUsername") = strArray(1)
            Session("xtPassword") = strArray(2)
            Session("xtServer") = strArray(3)
            Session("xtPortTextBox") = strArray(4)
            Session("xtDatabaseTextBox") = strArray(5)
            Session("xtTableTextBox") = strArray(6)
      End If
Next
        Set designdoc= Nothing
        Response.write h
     Case "Write XML"
          FileName2 = Session("FileName2")
          xmlpath = server.MapPath(FileName2)
          Response.Write("id='DIV102-WriteXML<br/>")
          Response.Write("FileName2:" & xmlpath & "#<br/>")
          Dim currentPage       : currentPage = (Request.QueryString("PageID"))
          Dim txProvider        : txProvider  = (Request.Form("txtProvider"))
          Dim txUsername        : txUsername  = (Request.Form("txtUsername"))
          Dim txPassword        : txPassword  = (Request.Form("txtPassword"))
          Dim txServer          : txServer  = (Request.Form("txtServer"))
          Dim txPortTextBox     : txPortTextBox  = (Request.Form("PortTextBox"))
          Dim txDatabaseTextBox : txDatabaseTextBox  = (Request.Form("DatabaseTextBox"))
          Dim txTableTextBox    : txTableTextBox  = (Request.Form("TableTextBox"))
          Response.Write("Prov:" & txProvider & "#    User:" & txUsername & "#    Pass:" & txPassword & "#    Serv:" & txServer & "#    Port:" & txPortTextBox & "#    DB:" & txDatabaseTextBox & "#    TB:" & txTableTextBox & "#<br/>")
Dim oXMLTextWriter, xmlpath, blnFileExist
Set oXMLTextWriter = New cXMLTextWriter
' add to top <?xml version="1.0"?> ("xml","version=""1.0""" & vbCrLf))
With oXMLTextWriter
   .WriteStartDocument "LoginDetails"
   .WriteElementString "Provider","sqloledb"
   .WriteElementString "Username","sa"
   .WriteElementString "Password","H6web97!"
   .WriteElementString "Server","Dinosaur1\sqlexpress"
   .WriteElementString "Port","4096"
   .WriteElementString "Database","AdminDB2"
   .WriteElementString "Table","AdminTable"
   .WriteEndDocument
End With
Response.write Server.HTMLEncode(oXMLTextWriter.xml)
set objXML = CreateObject("Microsoft.FreeThreadedXMLDOM")
objXML.async = False
blnFileExist = objXML.load(xmlpath)
        If not(blnFileExist) Then
objXML = Server.HTMLEncode(oXMLTextWriter.xml)
objXML.save(xmlpath) 'Line 79 Microsoft VBScript runtime error '800a01a8'Object required: '&lt;LoginDetails&gt;'
End If
    'Set objXMLv = nothing
    'Set xmlObj = nothing
    Set objXML = nothing
     Case Default
          Response.Write("You did not click a button")
End Select
Response.Write("</div>")
%>
cXMLTextWriter.txt
0
homeshopper
Asked:
homeshopper
  • 3
  • 2
1 Solution
 
Scott Fell, EE MVEDeveloperCommented:
Your missing LoginDetails.

Look at your code starting with,  Case "Write XML".   Below that you see CurrentPage, Provider, Username, Password etc. but you did not add a node for LoginDetails.
0
 
homeshopperAuthor Commented:
Thank you for your comment, The code I now have is as follows below:
The code prints out to screen via line:
Response.Write Server.HTMLEncode(oXMLTextWriter.xml)
<LoginDetails><Provider>sqloledb</Provider><Username>sa</Username><Password>H6web97!</Password><Server>Dinosaur1\sqlexpress</Server><Port>4096</Port><Database>AdminDB2</Database><Table>AdminTable</Table></LoginDetails>
When I add the line: objXML.save(xmlpath) in order to save file, I get error:
Microsoft VBScript runtime error '800a01a8' Object required: '&lt;LoginDetails&gt;'
For clarity the complete code is as follows:
Dim oXMLTextWriter, xmlpath, blnFileExist
Set oXMLTextWriter = New cXMLTextWriter
' add to top <?xml version="1.0"?> ("xml","version=""1.0""" & vbCrLf))
With oXMLTextWriter
   .WriteStartDocument "LoginDetails"
   '.WriteElementString "LoginDetails","login"
   .WriteElementString "Provider","sqloledb"
   .WriteElementString "Username","sa"
   .WriteElementString "Password","H6web97!"
   .WriteElementString "Server","Dinosaur1\sqlexpress"
   .WriteElementString "Port","4096"
   .WriteElementString "Database","AdminDB2"
   .WriteElementString "Table","AdminTable"
   .WriteEndDocument
End With
Response.Write Server.HTMLEncode(oXMLTextWriter.xml)
set objXML = CreateObject("Microsoft.FreeThreadedXMLDOM")
objXML.async = False
blnFileExist = objXML.load(xmlpath)
        If not(blnFileExist) Then
objXML = Server.HTMLEncode(oXMLTextWriter.xml)
objXML.save(xmlpath) 'Line 132 Microsoft VBScript runtime error '800a01a8'Object required: '&lt;LoginDetails&gt;'
End If
0
 
Scott Fell, EE MVEDeveloperCommented:
Is the node in your source file?
0
 
homeshopperAuthor Commented:
Not quite sure, but believe node is there.
It produces on screen the following:
The error only comes when trying to save file.
<LoginDetails><Provider>sqloledb</Provider><Username>sa</Username><Password>H6web97!</Password><Server>Dinosaur1\sqlexpress</Server><Port>4096</Port><Database>AdminDB2</Database><Table>AdminTable</Table></LoginDetails>
0
 
homeshopperAuthor Commented:
no solution found, just close question.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now