Don't know how to sort the datatable in dataset

legendgod

Regular
Joined
May 17, 2004
Messages
53
Location
Hong Kong
Hello everyone, I am a newbie to .NET and to this forum. Nice to meet everyone. :D

I have the problem as titled. I have 2 datatable named "tableA" and "tableB" in single dataset named "DS". DS is stored in session when first time it is filled with adaptor.

The datatables are sorted with appropiate SQL statement when it is called by adaptor. However, after I make some change to the datatables. ( using some test code like:
<CODE>
tableA= DS.Tables(0)
Dim updateRows as DataRow() = tableA.Select("schId = 44","schId")
if updateRows.Length > 0 then
For i=1 to updateRows.Length-1
updateRows(i).Item("hId") = 5
Next
end if

</CODE>

I want to sort the DS.Tables(0) before write it back to session. What should I do? Some ppl suggest me using Dataview but I don't know how to apply the change dataview made towards dataset. Any idea is helpful, thank you.
 
legendgod said:
Hello everyone, I am a newbie to .NET and to this forum. Nice to meet everyone. :D

I have the problem as titled. I have 2 datatable named "tableA" and "tableB" in single dataset named "DS". DS is stored in session when first time it is filled with adaptor.

The datatables are sorted with appropiate SQL statement when it is called by adaptor. However, after I make some change to the datatables. ( using some test code like:
<CODE>
tableA= DS.Tables(0)
Dim updateRows as DataRow() = tableA.Select("schId = 44","schId")
if updateRows.Length > 0 then
For i=1 to updateRows.Length-1
updateRows(i).Item("hId") = 5
Next
end if

</CODE>

I want to sort the DS.Tables(0) before write it back to session. What should I do? Some ppl suggest me using Dataview but I don't know how to apply the change dataview made towards dataset. Any idea is helpful, thank you.

Here's what you do, you sort the datatable into a dataview and never sort the datatable. Display the dataview in the place you need too, and always jsut sort the datatable as required.
 
Back
Top