RE: Dataview into new table ???

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Bin Song, MCP (anonymous_at_discussions.microsoft.com)
Date: 04/16/04


Date: Fri, 16 Apr 2004 06:06:04 -0700

Hi, Sjaakie,

You might try the following:

sendDS = ds.Clone()
Dim copyRows() As DataRow = ds.Tables("Items").Select("amount > 0")
Dim dt As DataTable = sendDS.Tables("Items")
Dim copyRow As DataRow
For Each copyRow In copyRows
  dt.ImportRow(copyRow)
Next

Hope this will help,

Bin Song , MCP
     
     ----- Sjaakie Helderhorst wrote: -----
     
     Hi,
     
     I've come a stage that I'm feeling an absolute idiot.
     Struggling with this issue for days and can't find a suitable answer.
     
     Have this dataset which 'amount' value can be updated. Need to send all
     records with 'amount > 0' to a webservice as a Datatable. (Ignorant as I
     might be) I Dim a new DataView (rowfilter 'amount > 0') and copy this into a
     new datatable:
     
     
     dv = New DataView(ds.Tables("Items"), _
           "amount > 0", _
           "barcode", _
           DataViewRowState.CurrentRows)
     
     Dim dt As New DataTable("Result")
     dt = dv.Table.Copy
     sendDS.Tables.Add(dt)
     
     However, sending this datatable (dt) to a webservice will send the entire
     source dataset (= huge)
     
     What am I doing wrong ...
     Is there a more suitable way of achieving this!?
     
     Thanks in advance.