Just when I thought I had a grasp on DataTables.
In the code below after making the Datatables and dataset I cant read the data from the Tables using the dataset.
What am I missing?
Thankyou.
Code:
using System;
using System.Data;
namespace JPADataSet
{
class Program
{
static void Main(string[] args)
{
DataTable pOD = new DataTable("pOD");
DataTable pODDG = new DataTable("pODDG");
DataSet POdataset = new DataSet("POdataset");
pOD.Columns.Add("First Column");
pODDG.Columns.Add("First Column");
POdataset.Tables.Add("pOD");
POdataset.Tables.Add("pODDG");
pOD.Rows.Add("hello");
pODDG.Rows.Add("goodbye");
Console.WriteLine(Convert.ToString(pOD.Rows[0][0])); //Works
Console.WriteLine(Convert.ToString(pODDG.Rows[0][0])); //Works
Console.WriteLine(Convert.ToString(POdataset.Tables[0].Rows[0][0])); //Dosnt Work
Console.WriteLine(Convert.ToString(POdataset.Tables[1].Rows[0][0])); // Doesnt work
Console.Read();
}
}
}
//System.IndexOutOfRangeException
//HResult = 0x80131508
//Message = There is no row at position 0.
// Source = System.Data.Common
//StackTrace:
//at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
// at System.Data.DataRowCollection.get_Item(Int32 index)
// at JPADataSet.Program.Main(String[] args) in C: \Users\tonya\source\repos\JPADataSet\JPADataSet\Program.cs:line 27