Forum: VB.NET |
Thema:
Re: TreeView aus Access2000-Tabelle |
Von:
G. Guest (
03.02.2005 12:26) |
Hi Paul,
hab mir deinen Code angegekuckt und korrigiert. Habe die Fehler in den Zeilen kommentiert. Über das Einfügen in die TreeView mach ich mir später einen Kopf
Richtiger Code:
Public Sub xml_fill()
'Next, you fill the adapter with data, naming the DataTable "CouponsRedeemed":
Dim xmlds As New Data.DataSet("Artikel")
'!! Dieser OleDBDataAdapter ist nicht nötig, du hast weiter unten xmladp als Adapter
'Dim xmloleadp As New OleDb.OleDbDataAdapter
Dim xmlcmd As New OleDb.OleDbCommand("Select * from Artikel", Me.OleDbConnection1)
xmlcmd.CommandTimeout = 30
Dim xmladp As New OleDb.OleDbDataAdapter
xmladp.TableMappings.Add("Table", "artikel")
Me.OleDbConnection1.Open()
'Falsch
'xmloleadp.SelectCommand = xmlcmd
'Richtig
'Du must den richtigen Adapter nehmen
xmladp.SelectCommand = xmlcmd
'Dann bekommst du hier keine Exception
xmladp.Fill(xmlds)
Me.OleDbConnection1.Close()
'Now, create an XmlDataDocument to wrap the DataSet. After this, doc is now ready to use, including all the base XmlDocument members:
Dim XmlDataDoc As New XmlDataDocument(xmlds)
'In this case, you can just use an XmlWriter to output the XmlDataDocument to the console:
Dim XmlTextWriter As New XmlTextWriter(Console.Out)
XmlTextWriter.Formatting = Formatting.Indented
XmlDataDoc.WriteTo(XmlTextWriter)
End Sub
Gruss Frank
Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!