xml and datasets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone,

I've created a dataset in Visual Studio and created a table structure with
the Tables property. I want to read an xml file in the dataset and display it
in the datagrad. The dataset is linked to the datagrid in VS.
But I think that the xml file isn't read properly in the Table definition of
the dataset.
That is because the datagrid doesn't show the perfect column headers.

my code is:
DataSetAdressen.ReadXml("c:\\lessius\\adressen.xml",
XmlReadMode.IgnoreSchema);
DataGridAdressen.DataSource = DataSetAdressen;
DataGridAdressen.DataMember = "Adres";

thanks for the answers,

Filip
 
this one worked w/out a hitch for me. this is from a web app


Private Sub read_file()
Dim aFile, FinalFile As String
aFile = txtFile.Text
FinalFile = "C:\Re_Class\" & aFile & ".xml"
Dim xmlFile As String
xmlFile = FinalFile
Dim ds As New DataSet
ds.ReadXml(xmlFile)
DataGrid1.DataSource = ds
DataGrid1.DataBind()
End Sub

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
Hi Filip,

My guess is your problem actualy has nothing to do with reading XML, the
reason being that you specify IgnoreSchema. If you skip reading the
addresses from the XML file, I'm sure you'll still see column headers that
are not what you are expecting. What you need to do is look at the Caption
property of the DataColumns of your Adres table. You can iterate through all
the columns in the table like this:

dim dc as DataColumn
for each dc in DataSetAdressen.tables("Adres").columns
Debug.writeline(dc.Caption)
next

You will see the Captions as they are for your table fields, and you can
change them to whatever you want.
 
Back
Top