DataSet DataTable Merge

patrick

Well-known member
Joined
Dec 5, 2021
Messages
259
Programming Experience
1-3
Hello.

DataSet ds ----- Tables --- ds.Tables[0] ~ [5]

I want to merge --- ds.Tables[0]~[5]

Error : Datatable tempdt;
for i=0 ; i < ds.Tables; i++)
{
tempdt.merge(ds.Tables [ i ] )
}

Error CS0165 use of unassigned local bariable 'tempdt'
 
Last edited:
You never actually assign anything to that variable. How can you call Merge on something that doesn't exist? If you want to call a method on a DataTable then you have to have a DataTable to call it on.
 
Do you want to maintain those existing DataTables? If not, you should just start with the first one and then merge the other five into that. Otherwise, you can create a copy of the first one and then merge the other five into that. Of course, one has to wonder why you have six DataTables with the same schema and different data in the first place.
 
Do you want to maintain those existing DataTables? If not, you should just start with the first one and then merge the other five into that. Otherwise, you can create a copy of the first one and then merge the other five into that. Of course, one has to wonder why you have six DataTables with the same schema and different data in the first place.


I was here to do this.
 
As a courtesy to the people you're asking for help, please learn how to use CODE tags. It's one select highlight operation and one button click. It's significantly easier than even a task like logging onto the forum, so I know you're more than capable of forming a nice, readable post
 
Back
Top Bottom