CTE Solutions
 Search
Friday, July 30, 2010 ..:: Community Forum ::.. Register  Login
 Community Forum Minimize
     
  .NET Development  MCTS 70-536 Study Group  problem/solution for Chapter 7; Lesson 5; Exercise 2, LoadDataSetsWithXml  

 problem/solution for Chapter 7; Lesson 5; Exercise 2, LoadDataSetsWithXml 
 
Flip
72 posts
problem/solution for Chapter 7; Lesson 5; Exercise 2, LoadDataSetsWithXml
Posted: 13 Mar 08 7:33 PM (N/A)
 
If you are trying out this exercise, you might have run into the same problem I did, it won't work! :<

The problem is two fold, one is they told tell you that you have to have a private DataSet variable declared in your code and second, it has to be a class member variable, not a method variable for the load schema or load data.

My code looks something like this. If got it to run, great! If not, hopefully this will help.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace pch10_LoadDataSetsWithXml
{
public partial class Form1 : Form
{
DataSet northwindDataSet = new DataSet();

public Form1()
{
InitializeComponent();
}

private void LoadDataButton_Click(object sender, EventArgs e)
{
northwindDataSet.ReadXml(@"c:\temp\Northwind.xml");
Console.WriteLine("Done loading");
}

private void loadSchemaButton_Click(object sender, EventArgs e)
{
northwindDataSet.ReadXmlSchema(@"c:\temp\Northwind.xsd");
customersDataGridView.DataSource = northwindDataSet.Tables["Customers"];
ordersDataGridView.DataSource = northwindDataSet.Tables["Orders"];
}
}
}
 
   .NET Development  MCTS 70-536 Study Group  problem/solution for Chapter 7; Lesson 5; Exercise 2, LoadDataSetsWithXml
 
 
   

Search   

Copyright 2008 Ottawa .NET Community   Terms Of Use  Privacy Statement
Portal engine source code is copyright 2002-2010 by DotNetNuke. All Rights Reserved