Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Experts,

I have a dataset dtres and I want to insert data as below. My classlist has Items greater than 0. So I want to add the data based on condition from another datatable. Data should be added as follows
Classlist Item 1 data should go in dataset.table(1)
classList Item 2 data should go in dataset.table(2)
classlist Item 3 data should go in dataset.table(3)

VB
If classlist.Count > 0 Then
       For i As Integer = 0 To classlist.Count - 1
         dtres.Tables.Add(dtres.Tables(i))
         ds.Tables(0).DefaultView.RowFilter = "FECLS = " + classlist(i).ToString().Trim()
         For t As Int16 = 0 To dtres.Tables.Count - 1
          dtres.Tables(i)= ds.Tables(0).DefaultView.ToTable())
         Next
       Next


Can anyone help me with this please?
Posted
Updated 15-May-15 8:11am
v2
Comments
OriginalGriff 15-May-15 14:45pm    
Well I can't - but that may be because you haven't told us what the problem is.
What does that code do that you didn't expect, or not do that you did?
What help are you needing?
sudevsu 15-May-15 14:57pm    
Rowfilter of FECLS= 1 gives a set of rows in ds.Tables(0).Defaultview.ToTable().
Similarly 2,3, so on. Now each time it filters the Data I want to add filtered data in dtres(Dataset).Tables(1), Tables(2), Tables(3) respectively.
My code didn't help me with the above.
Richard Deeming 15-May-15 15:04pm    
Isn't this the same question you posted yesterday?
How to get unique datatables from single dataset[^]
sudevsu 18-May-15 8:38am    
actually not. That was different one. and it is resolved.

1 solution

Have a look here: Splitting a dataset in to datatables (c#)[^]. You can convert code there provided via using telerik online converter[^].
 
Share this answer
 
Comments
sudevsu 18-May-15 8:39am    
Awesome. This is what I am looking for. Great! Thank you
Maciej Los 18-May-15 8:43am    
You're very welcome ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900