Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 25, 2008 12:31 PM by asyed4u
Member
13 Points
49 Posts
Aug 25, 2008 11:12 AM|LINK
Hi Guys, Can you tell me how many DataTable I can add to a DataSet at a time?
And what is the process of adding them?
Participant
1307 Points
268 Posts
Aug 25, 2008 12:31 PM|LINK
hi...
DataSet Ds=new DataSet;
string DataTableName;
for(i=0;i<5;i++) //u can specify ... without FOR LOOP ....
{
DataTableName = "MyDataTable"+ i.ToString(); // optional
DataTable dt=new DataTable(DataTableName); // u can specify .... directly different table names
dt.Columns.Add(
while(condition) // Optional ....if add more rows
dt.Rows.Add(new object[] { "1", "Test" });
Ds.Tables.Add(dt);
} //for loop end
=========================================
retrive the table from dataset as ..........
anyDatacontrol=ds.Tables[
spillbean
Member
13 Points
49 Posts
Adding DataTable to DataSet
Aug 25, 2008 11:12 AM|LINK
Hi Guys, Can you tell me how many DataTable I can add to a DataSet at a time?
And what is the process of adding them?
asyed4u
Participant
1307 Points
268 Posts
Re: Adding DataTable to DataSet
Aug 25, 2008 12:31 PM|LINK
hi...
DataSet Ds=new DataSet;
string DataTableName;
for(i=0;i<5;i++) //u can specify ... without FOR LOOP ....
{
DataTableName = "MyDataTable"+ i.ToString(); // optional
DataTable dt=new DataTable(DataTableName); // u can specify .... directly different table names
dt.Columns.Add("SNO", Type.GetType("System.String"));dt.Columns.Add(
"SNAME", Type.GetType("System.String"));while(condition) // Optional ....if add more rows
{
dt.Rows.Add(new object[] { "1", "Test" });
}Ds.Tables.Add(dt);
} //for loop end
=========================================
retrive the table from dataset as ..........
anyDatacontrol=ds.Tables[
"anytablenameBUTexistingINtheDataset"];