Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8068827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:49:05+00:00 2026-06-05T12:49:05+00:00

I have created a data table using disconnected class, also created the data set,xml

  • 0

I have created a data table using disconnected class, also created the data set,xml file, now I want to load that table in a grid. I wrote all my code under program.cs, but when I tried to access the data set object from the form load method, the data set object is not recognized. The code is here:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Data;
using System.IO;

namespace DisconnectedClassDemo
{
    public class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]


        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());



            DataTable studentInfo = new DataTable("studentinfo");

            DataColumn StudentID = new DataColumn("studentID");
            StudentID.DataType = typeof(int);
            StudentID.Caption="StudentID";
            StudentID.AutoIncrement = true;
            StudentID.AutoIncrementSeed = 1;
            StudentID.AutoIncrementStep = 1;


            DataColumn Name = new DataColumn("StudentName", typeof(string));
            Name.MaxLength = 50;
            Name.AllowDBNull = false;
            Name.Caption = "StudentName";

            DataColumn Roll = new DataColumn("StudentRoll", typeof(int));
            Roll.Caption = "StudnetRoll";

            studentInfo.Columns.Add(StudentID);
            studentInfo.Columns.Add(Name);
            studentInfo.Columns.Add(Roll);

            studentInfo.PrimaryKey = new DataColumn[] { StudentID };

            //DataRow rowobj = studentInfo.NewRow();
            //rowobj["studentName"] = "Badhon";
            //rowobj["studentRoll"] = "004";

            //studentInfo.Rows.Add(rowobj);


            DataSet ds = new DataSet("dataset");
            ds.Tables.Add(studentInfo);

            ds.WriteXmlSchema("D:\\Student.xsd");
            ds.WriteXml("D:\\student.xml");



            ds.ReadXmlSchema("d:\\student.xsd");
            ds.ReadXml("D:\\student.xml");







        }
    }



}


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;
using System.IO;

namespace DisconnectedClassDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //dataGridView1.DataSource= 
            //dataGridView1.DataMember=

        }




    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:49:07+00:00Added an answer on June 5, 2026 at 12:49 pm

    Why are you writing the data set to the file system? Aren’t you trying to create an in memory dataset and the access that dataset? Try declaring the dataset on the form itself.

    Try this:

                DataTable studentInfo = new DataTable("studentinfo");
    
            DataColumn StudentID = new DataColumn("studentID");
            StudentID.DataType = typeof(int);
            StudentID.Caption = "StudentID";
            StudentID.AutoIncrement = true;
            StudentID.AutoIncrementSeed = 1;
            StudentID.AutoIncrementStep = 1;
    
    
            DataColumn Name = new DataColumn("StudentName", typeof(string));
            Name.MaxLength = 50;
            Name.AllowDBNull = false;
            Name.Caption = "StudentName";
    
            DataColumn Roll = new DataColumn("StudentRoll", typeof(int));
            Roll.Caption = "StudnetRoll";
    
            studentInfo.Columns.Add(StudentID);
            studentInfo.Columns.Add(Name);
            studentInfo.Columns.Add(Roll);
    
            studentInfo.PrimaryKey = new DataColumn[] { StudentID };
    
            DataSet ds = new DataSet("dataset");
            ds.Tables.Add(studentInfo);
    
            var rw = ds.Tables[0].NewRow();
    
            rw["StudentName"] = "Badhon";
            rw["StudentRoll"] = 004;
    
            ds.Tables[0].Rows.Add(rw);
    
            MessageBox.Show(ds.Tables[0].Rows.Count.ToString());
    
            dataGridView1.DataSource = ds.Tables[0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Area class using Linq-to-SQL. Now I want to create a
i have created table using Sqlite3.and also inserted record in that table.its running successfully.but
I have a in memory data base created by using the disconnected class. I
I have a DataTable that I manually created and loaded with data using C#.
I have a table that was created using this mysql statement below. CREATE TABLE
I have created an SQLite FTS3 table that I am using within the Android
I have created HTML TABLE from JSON data of PHP using JQuery. After creating
I have created an archive table which will store data for selecting only. Daily
I have a data.frame and I'm trying to create a frequency table that shows
I have data in 2 tables, and I want to create a report. Table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.