Dataview Copy

D

Dianna K.

I have a dataview which I am assigning to a Datatable (I
am doing this because currently Crystal Reports will not
accept a dataview as a Reportsource -- The recommended
work-around is to assign dataview to datatable).

The dataview is being filtered. However when I assign it
to the datatable it is not filtered. I put some debug
code in and the Dataview has 8 records then I assign it to
a new datatable. When I check the row count of the
Datatable it has 34 rows...??
Shouldn't the dataview only copy the 8 filtered rows???



Dim dtCrystal As DataTable

dtCrystal = dvGrid.Table.Copy


oRpt.SetDataSource(dtCrystal)
crvReport.ReportSource = oRpt
crvReport.PrintReport()

Any help would be great
Dianna
 
W

William Ryan

No, you are copying the underlying DataTable. As such, there's no filter.

I think you can foreach the rows in teh dataview and add them to the other
datatable.

Hth,

Bill
 
D

Dianna K

Hi Bill,

I tried however no such luck :( I am still getting the
entire un-filtered dataset.

MsgBox("Filter Count" & dvGrid.Count)

rptDS = OutDS.Clone 'copy structure Only

For Each objRow In dvGrid.Table.Rows
NewRow = rptDS.Tables(0).NewRow
rptDS.Tables(0).Rows.Add(NewRow)
Next

MsgBox("NEW TABLE " & rptDS.Tables(0).Rows.Count)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top