Advertisement

07.23.2008 at 03:22AM PDT, ID: 23587912
[x]
Attachment Details

Visual C# Windows Application with XML dataset / database

Asked by firepol in C# Programming Language, Microsoft Visual C#.Net, .NET Framework 2.0

Tags: Microsoft, Visual Studio, 2005 Pro, c#

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\XmlApp\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,

--firepolStart Free Trial
[+][-]07.23.2008 at 04:55AM PDT, ID: 22068105

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 04:59AM PDT, ID: 22068135

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 05:02AM PDT, ID: 22068165

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 05:06AM PDT, ID: 22068194

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 05:06AM PDT, ID: 22068199

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 05:14AM PDT, ID: 22068262

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 05:20AM PDT, ID: 22068319

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 05:32AM PDT, ID: 22068443

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 05:50AM PDT, ID: 22068633

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 05:51AM PDT, ID: 22068645

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 05:55AM PDT, ID: 22068688

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 06:09AM PDT, ID: 22068851

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 06:23AM PDT, ID: 22069026

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Microsoft Visual C#.Net, .NET Framework 2.0
Tags: Microsoft, Visual Studio, 2005 Pro, c#
Sign Up Now!
Solution Provided By: margajet24
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.23.2008 at 07:22AM PDT, ID: 22069568

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628