Check the junk of code to generate Schema at the Runtime. Generating the code to create a DataTable, replete with associated DataColumns.
private static void productDataTable(DataSet ds) { DataTable products = new DataTable("Products");
//Generating Columns
productTable.Columns.Add(new DataColumn("ProductID", typeof(int))); productTable.Columns.Add(new DataColumn("ProductName", typeof(string))); productTable.Columns.Add(new DataColumn("SupplierID", typeof(int))); productTable.Columns.Add(new DataColumn("CategoryID", typeof(int))); productTable.Columns.Add(new DataColumn("QuantityPerUnit", typeof(string))); productTable.Columns.Add(new DataColumn("UnitPrice", typeof(decimal))); //Adding the Table to the DataSet]
ds.Tables.Add(products);
}
Now we'll call the method
productDataTable(ds); dad.Fill(ds, "Products"); foreach (DataRow r in ds.Tables[0].Rows) { DisplayLabel.Text = r[0].ToString() + "--" + r[1].ToString() + " "; }
cheers
|
No responses found. Be the first to respond and make money from revenue sharing program.
|