nanban
asked on
create two datatable from single datatable
Hi,
I have a dataset datatable
select ORDER ,
DESCRIPTION,
FIRSTNAME,
LASTNAME,
ADDRESS,
ZIP
FROM Order
I need to select only Order and description and insert in to the another datatable
then select other firstname,lastname,address ,zip to another datatable and assign this two datatable to new dataset
how to do that?
regards.
Nanban
I have a dataset datatable
select ORDER ,
DESCRIPTION,
FIRSTNAME,
LASTNAME,
ADDRESS,
ZIP
FROM Order
I need to select only Order and description and insert in to the another datatable
then select other firstname,lastname,address
how to do that?
regards.
Nanban
ASKER
What is totable?
I thought only using datarow we can get the required column and send in to table.
I thought only using datarow we can get the required column and send in to table.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If i want to add autoincrement column with the table how to do that?
to add an autoincrement column to a datatable you would do something like:
DataColumn workColumn = newTable2.Columns.Add("Cus tomerID", typeof(Int32));
workColumn.AutoIncrement = true;
workColumn.AutoIncrementSe ed = 1;
workColumn.AutoIncrementSt ep = 1;
DataColumn workColumn = newTable2.Columns.Add("Cus
workColumn.AutoIncrement = true;
workColumn.AutoIncrementSe
workColumn.AutoIncrementSt
ASKER
When we are using autoincrement column after totable the previous column dont have any value so how to add the b4 totable. if are adding autoincrement column b4 totable then calling totable delete the autoincrement column. what to do for that?
with the technique i posted add the autoincrement replacing newTable2 with the name of your original datatable. then proceed with the totable technique and because the way we constructed it it will drop the autocolumn and the new tables wont have it.
ASKER
Actually what is the problem is I need to create two auto increament column one is orderid and another one is contackkey and i need to releate the newly created table with primarykey foreignkey relationship so newly created order table has four coulmns contatkey,orderid,ORDER,DE SCRIPTION first i need to insert contact table and then with the autogenerated column contackkey i need to insert in to order table with relationship
Shall i create the new thread or proceed with this thread... coz already we closed the thread :-) ?
Regards
Nanban.
Shall i create the new thread or proceed with this thread... coz already we closed the thread :-) ?
Regards
Nanban.
i believe the proper way to do it would be to create a new thread, in any case to get help from other experts as well. just put your new question and a link to this one if people want to see where you stand.
ASKER
Hi
I have created a new thread for this...
https://www.experts-exchange.com/questions/22065240/one-dataset-table-to-multiple-dataset-table.html
thanks a lot.....
Regards,
Nanban.
I have created a new thread for this...
https://www.experts-exchange.com/questions/22065240/one-dataset-table-to-multiple-dataset-table.html
thanks a lot.....
Regards,
Nanban.
DataView dv = new DataView(datatable);
DataTable newTable1 = dv.ToTable("OrderDesc",
false, new string[] { "ORDER", "DESCRIPTION" });
DataTable newTable2 = dv.ToTable("Rest",
false, new string[] { "FIRSTNAME", "LASTNAME", "ADDRESS", "ZIP" });
now you need to create a dataset and add these two new tables.
DataSet dataset1 = new DataSet("MyNewDataset");
dataset1.Tables.Add(newTab
dataset1.Tables.Add(newTab