When you are using strongly typed DataSets
, you declare the tables and dataadapters on the designer. The DataTables
then are already part of that DataSets
, hence you don't need to to add them again to it.
That explains why the dataset contains two tables instead of one. Because of the same reason you get the exception. You have added the rows to your manually created table and not to the declaratively added.
But
dg.General[0].Rows[0].Value
accesses the auto-generated DataTable
which is still empty.
So you just have to use the available table:
DSGeneral dg = new DSGeneral();
DSGeneral.GeneralRow r = dg.General.NewGeneralRow();
r.Code = "code";
r.Value = "7";
dg.General.AddGeneralRow(r);