Hello, I'm new to Visual Studio 2005 Pro and to C#.
I'd like to create a simple application in Windows that will store its data in an XML database and display the data in Grid (DataGridView).
I've found this tutorial, but it's for VB, not C#...
http://articles.techrepublic.com.com/5100-10878_11-5116182.html
I've followed the tutorial, but to summarize I did the following:
I created a Visual C# Windows Application Project, I added a dataset.xsd and created 2 columns. Then I added the DataGridView in the Form, then I chose the datasource: Other Data Sourcers > Project Data Sources > DataSet > DataTable1. By doing so, a table showing the columns I created in the XSD DataSet is displayed.
I've created an XML called mydata.xml and inserted some values there. I'd like to display them.
With the Visual Basic version of the project I can populate the grid from the XML values by adding in the page load these 3 lines:
Dim ds As New DataSet
ds.ReadXml("mydata.xml")
DataGridView1.DataSource = ds.Tables(0)
With the C# version of the project I try to achieve the same, but I can't, I tried to insert in the page load the following:
DataSet ds = new DataSet();
ds.ReadXml("mydata.xml");
Grid1.DataSource = ds.Tables(0);
When I run it I get this error:
Error 1 'XmlApp.DataSet.Tables' is a 'property' but is used like a 'method' D:\Documents\Visual Studio 2005\Projects\XmlApp\XmlAp
p\Form1.cs
22 35 XmlApp
Now my questions are:
1) how can I display the contents of the XML in the grid, as done in the Visual Basic example?
2) I want that if I add or remove values from the Grid and I can click on a "save" button: all the contents should be saved in the XML, by overwriting the old version or updating/adding the new values (what is easier to do?), how can I do this?
Thanks for letting me know, best regards and thanks for understanding that I'm a beginner,
--firepol