How do I add DataTables to a DataSet in ASP.NET 2.0 / C#?

I would like to use a DataSet instead of a bunch of scattered DataTables. How do I add DataTables to a DataSet and reference those tables from the DataSet? Here is an example that I'm trying to do:

        DataSet dbTable = new DataSet("Structure");

        DataTable fileTable = new DataTable("Files");
        fileTable.Columns.Add("Name", typeof(String));
        fileTable.Columns.Add("Size", typeof(Double));
        fileTable.Columns.Add("Directory", typeof(Double));

        DataTable directoryTable = new DataTable("Directories");
        directoryTable.Columns.Add("Name", typeof(string));
        directoryTable.Columns.Add("Parent", typeof(string));
        directoryTable.Columns.Add("CreationTime", typeof(DateTime));
Who is Participating?
Elvio Lujan.Net Senior DeveloperCommented:
David H.H.LeeCommented:
Dear bemara57,
Use this instead:
DataSet dbTable = new DataSet("Structure");


dbTable .Tables["Files"] - table "Files"
dbTable .Tables["Directories"] - table "Directories"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.