Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Dataview back to Datatable

Status
Not open for further replies.

IndyGill

Technical User
Jan 15, 2001
191
GB
Hi

I was wondering is it possible to convert a dataview back to a datatable? The reason I ask is that I am working with objects that a Backend developer has written which give me datatables.

Sometimes I have to put them into dataviews to display the correct data, but when I want to save the object back to the database via the object I need to return a datatable.

So is it possible for me to convet a dataview back to datatable?

Many thanks in advance

PS Im working in VB.Net
 
When you update a DataView, the DataTable that it is referencing is changed. So it's been my experience that you should be able to pass your DataTable to the Backend process and all your changes will be there.

JohnD
"What we need is a list of specific unknown problems we will encounter.
 
Code:
DataView   _oDv = new DataView();
DataTable  _oDt = _oDv.Table;

Should be pretty much exactly the same in VB.

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Im not sure if I have explained myself properly, here is some sample code of what I am trying to do:

Dim obj as customers
Dim ctrl as baseControl ' Contains all connection details
Dim ds as CustomersDataSet
Dim dt as customersDataTable
Dim dv as dataview
Dim drv As DataRowView

Private Sub Page Load

obj = New Customers(ctrl)
obj.load(ds.Customers)
dt = ds.Customers

'Put datatable into dataview to filter spsecific customers
dv =New Dataview(dt)
dv.RowFilter = "CustomerType = 10"

'Then I want to update the value for these specific rows if they happen to meet a requirment
If each drv in dv
If IsNothing(drv("ColumnX") then
drv("ColumnX") = "Something"
End if
End If

obj.save(dv) ' However this object really wants a datatable
' By putting a dataview to the save object
' breaks the object

End Sub


However I need to put the object in a dataview in order to do the filter. But I cant save the dataview back to the object as the object only wants as datatable

So I thought a few opions I might have is to eithier

1) Try and do a filter with a datatable (without puting it inot a dataview, but im to sure if this is possible

2) Go back to the backend developer and ask him to give me an object that does the filter for me

Any ideas?
 
As in my previous post...

Code:
obj.save(dv.Table) ' However this object really wants a datatable
             ' By putting a dataview to the save object 
             ' breaks the object

I've never tried this with filtering though... Let me know whether or not it works.

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
I tried it using .RowFilter and .RowStateFilter, but it dumps the whole dataview into the datatable.

JohnD
"What we need is a list of specific unknown problems we will encounter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top