ADO+ enables you to create tables externally and then add them to an existing dataset. To create a DataTable, see section 3.2.2
Note For this release, you should add a newly created table to the dataset prior to populating it with data. In the current version, if the table does not have an associated dataset, we create and assign one in invisibly.
The following example constructs a DataSet (ds), adds a new DataTable named "Orders," and adds three columns (OrderID, OrderQuantity, and CustID) to the DataTable. Finally, the code sets the OrderID column as the primary key column.
[VB] ds.Tables.Add(New DataTable("Orders")) ds.Tables("Orders").Columns.Add("OrderID", System.Type.GetType("System.Int32")) ds.Tables("Orders").Columns.Add("OrderQuantity", _ System.Type.GetType("System.Int32")) ds.Tables("Orders").Columns.Add("CustID", _ System.Type.GetType("System.Int32")) ds.Tables("Orders").PrimaryKey = New DataColumn(ds.Tables.Columns("Orders"), _ ds.Tables.Columns("OrderID")) ' Or Dim workTable As DataTable = New DataTable("Orders") workTable.Columns.Add("OrderID", System.Type.GetType("System.Int32")) workTable.Columns.Add("OrderQuantity", System.Type.GetType("System.Int32")) workTable.Columns.Add("CustID", System.Type.GetType("System.Int32")) ds.Tables("Orders").PrimaryKey = _ New DataColumn(ds.Tables("Orders").Columns("OrderID")) ds.Tables.Add(workTable) [C#] ds.Tables.Add(new DataTable("Orders")); ds.Tables["Orders"].Columns.Add("OrderID", System.Type.GetType("System.Int32")); ds.Tables["Orders"].Columns.Add("OrderQuantity", System.Type.GetType("System.Int32")); ds.Tables["Orders"].Columns.Add("CustID", System.Type.GetType("System.Int32")); ds.Tables["Orders"].PrimaryKey = new DataColumn[]{ds.Tables["Orders"].Columns["OrderID"]}; // Or DataTable workTable = new DataTable("Orders"); workTable.Columns.Add("OrderID", System.Type.GetType("System.Int32")); workTable.Columns.Add("OrderQuantity", System.Type.GetType("System.Int32")); workTable.Columns.Add("CustID", System.Type.GetType("System.Int32")); ds.Tables["Orders"].PrimaryKey = new DataColumn[]{ds.Tables["Orders"].Columns["OrderID"]}; ds.Tables.Add(workTable);