|
-
Mar 9th, 2003, 03:52 PM
#1
Thread Starter
New Member
Datasets
Ive been through all the help files but i can't seem to find what i'm looking for. I need to know how to add a new table to the dataset during run time. If anyone could help me that would be great.
-
Mar 9th, 2003, 04:08 PM
#2
PowerPoster
I'm not at my dev machine, but all you need to do is create an instance of the data table class and add it to the dataset's table collection.
-
Mar 9th, 2003, 04:10 PM
#3
Frenzied Member
Dim myTable as DataTable
myDataset.Tables.Add(myTable)
Didn't mean to repeat you Lethal, It seems we were answering the same time.
Last edited by Lunatic3; Mar 9th, 2003 at 04:16 PM.
-
Mar 9th, 2003, 04:17 PM
#4
PowerPoster
Lunatic,
Don't forget you need to call the object's constructor to create an instance. 
Code:
Dim myTable as New DataTable()
-
Mar 9th, 2003, 04:28 PM
#5
Frenzied Member
Oh Sure, Thanks
-
Mar 9th, 2003, 05:17 PM
#6
Thread Starter
New Member
Thanks
thanks everyone for your help, your advice help but the only problem now is that the new table that is created dose not have the same colums as my first original table. Can you help ?
-
Mar 9th, 2003, 06:39 PM
#7
PowerPoster
Try the Clone() method:
Code:
using System;
using System.Data;
class DataExample {
static void Main() {
DataTable dt = new DataTable("MyDataTable");
dt.Columns.Add(new DataColumn("Id"));
DataTable clone = dt.Clone();
foreach(DataColumn c in clone.Columns) {
Console.WriteLine("Column Name: {0}", c.ColumnName);
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|