Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: XML and ADO (VB) >Thread Next - Re: XML and ADO (VB) Re: XML and ADO (VB)To: NULL Date: 3/30/2009 4:25:00 AM Ok, I just want to open an xml file and later change some settings in it.
Here is my code:
Set objRS = CreateObject("ADODB.Recordset")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
strSTVProgOrdner ="D:\TSMLogReporter\"
strSTVTmpOrdner = strSTVProgOrdner & "tmp"
strSTVDBFile = strSTVTmpOrdner & "\" & "stvdb.xml"
strSTVConn = "Provider=Microsoft.Jet.OLEDB.4.0"
If objFSO.FileExists(strSTVDBFile) Then
'objRS.Open strSTVDBFile, strSTVConn
objRS.Open strSTVDBFile, strSTVConn, adOpenForwardOnly,adLockReadOnly
objRS.Fields.Append "ID", adInteger
objRS.Fields.Append "Name", adChar, 64
objRS.Fields.Append "Notiz", adChar, 2048
Response.Write "Recordset, sortiert nach Namen und ID:<br>" & VbCrLf
objRS.Sort = "Name DESC, ID ASC"
objRS.MoveFirst
While Not objRS.EOF
Response.Write objRS("ID") & " "
Response.Write objRS("Name") & "<br>" & VbCrLf
objRS.MoveNext
Wend
objRS.Sort = ""
Response.Write "<br>" & VbCrLf
objRS.Save strSTVDBFile, adPersistXML
objRS.Close
Else
Set objSTVDBFile = objFSO.OpenTextFile(strSTVDBFile, ForWriting, vbTrue)
'objSTVDBFile.WriteLine "<HTML></HTML>"
objSTVDBFile.Close
'objRS.Open strSTVDBFile, strSTVConn
objRS.Open strSTVDBFile, strSTVConn, adOpenForwardOnly, adLockReadOnly
objRS.Fields.Append "ID", adInteger
objRS.Fields.Append "Name", adChar, 64
objRS.Fields.Append "Notiz", adChar, 2048
'objRS.Open
objRS.AddNew
objRS("ID") = 1
objRS("Name") = "Christian"
objRS("Notiz") = "Dies ist eine sehr lange Notiz " & Space(900) & "!"
objRS.AddNew
objRS("ID") = 2
objRS("Name") = "Stefan"
objRS("Notiz") = "Dies ist eine weitere, sehr lange Notiz " & Space(900) &
"!"
objRS.AddNew
objRS("ID") = 3
objRS("Name") = "Guenter"
objRS("Notiz") = "Dies ist eine kurze Notiz !"
Response.Write "Werte des zweiten Datensatzes:<br>" & VbCrLf
objRS.AbsolutePosition = 2
Response.Write objRS("ID") & " " & objRS("Name")
Response.Write "(" & objRS("Notiz") & ")<br>" & VbCrLf
Response.Write "Recordset enthaelt " & objRS.RecordCount & "
Datensaetze.<br>"
Response.Write "<br>" & VbCrLf
Response.Write "<br>" & VbCrLf
objRS.Save strSTVDBFile, adPersistXML
objRS.Close
Set objRS = Nothing
End If
I got the error:
Provider error '80040e4d'
Authentication failed.
/testxml2.asp, line 37
The part with the editing is not realized ... just need to connect and
retrieve at first.
Thanks
"Martin Honnen" wrote:
> Juan wrote:
>
> > I want to use ADO to work with an XML file. - Perhaps to change some values
> > in it.
> > I've found a good example on http://www.aspheute.com/artikel/20000516.htm
> > (german) and it works.
> >
> > At the end of the site it is mentioned that I can use objRS.open xmlfile to
> > open an xml file and objRS.save to save an xml file.
> >
> > But it fails ...
>
> What exactly have you tried? What exactly happens when you say "it fails"?
> Show us your code, the exact error you get, otherwise we can't help.
>
>
>
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
