Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XML and ADO (VB)

From: Juan@-----------.---------.---
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/
> 


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent