CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Feb 2003
    Location
    Germany
    Posts
    89

    [RESOLVED] Accessing DataTables from Windows Form

    Hi, just started playing around with C#, and ran promptly into a problem. So here is -I think - a common newbie question:
    Using VS9 and .NET 4.0, I used the designer to construct a solution with a dataset (DataSet1) with DataTables(DataTable1,DataTable2) and a Windows Form (Form1) with Datagridviews for the Tables - no own coding so far. Then I tried to access a Table from Form1, which failed.

    DataSet1:
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    
    namespace CSWF {
    
        public partial class DataSet1
        {
    
        }
    }
    Form1:
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    
    namespace CSWF
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
    
           
    //My attempt to deal with the data tables:     
                try
                {
                     DataTable1.ReadXML("Set1.XML",System.Data.XmlReadMode.Auto);
    
                }
                catch (System.IO.FileNotFoundException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
    }
    How can I enable Form1 to access DataTable1 ?

    Thx adv.
    Last edited by Wild Thing; November 9th, 2010 at 10:28 AM.
    prepare that the light at the end of your tunnel is just a freight train coming your way - metallica

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured