473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How do I turn a Dataview with a rowfilter into a table?

I have a Dataview with a rowfilter on and I want to create a DataTable from
that filtering!

It's because I need to set that Table as a property in a special class that
I have.. and I can't change the class to use Dataviews instead so I need to
do this

best regard
/lars
Nov 20 '05 #1
4 1863
I think you will have to iterate through the rows and add them to a table.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:OP**************@tk2msftngp13.phx.gbl...
I have a Dataview with a rowfilter on and I want to create a DataTable from that filtering!

It's because I need to set that Table as a property in a special class that I have.. and I can't change the class to use Dataviews instead so I need to do this

best regard
/lars

Nov 20 '05 #2
Yeah I found a C# Example about it that that sucked, but I got the idea and
made this!

Dim myTable As DataTable = dvCodes.Table.Clone

Dim enumCodes As IEnumerator = dvCodes.GetEnumerator

While enumCodes.MoveNext

Dim myRowView As DataRowView = enumCodes.Current

Dim newRow As DataRow = myTable.NewRow

Try

newRow("CREG_ID") = myRowView("creg_ID")

newRow("creg_regType") = myRowView("creg_regType")

newRow("creg_code") = myRowView("creg_code")

newRow("creg_text") = myRowView("creg_text")

newRow("creg_catId") = myRowView("creg_catId")

newRow("creg_unit") = myRowView("creg_unit")

myTable.Rows.Add(newRow)

Catch ex As Exception

MsgBox(ex.Message)

End Try

End While

/Lars


"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> skrev i
meddelandet news:Om**************@TK2MSFTNGP09.phx.gbl...
I think you will have to iterate through the rows and add them to a table.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:OP**************@tk2msftngp13.phx.gbl...
I have a Dataview with a rowfilter on and I want to create a DataTable

from
that filtering!

It's because I need to set that Table as a property in a special class

that
I have.. and I can't change the class to use Dataviews instead so I need

to
do this

best regard
/lars


Nov 20 '05 #3
Hi Lars,

In addition to OHM (a very slight addition),

You can also have a look at the datatable.select with the same filtering.
That gives direct a datarowcollection.

Cor
Nov 20 '05 #4
Lars,
I find its easier to use DataTable.ImportRow to create the second table,
rather then manually copying each column. Something like:

Dim inputTable As DataTable

Dim output As DataTable = inputTable.Clone

' import based on a DataView
Dim input As DataView = dvCodes
For Each row As DataRowView In input
output.ImportRow(row.Row)
Next

' import based on a DataTable.Select
Dim input() As DataRow = inputTable.Select(filterExpression)
For Each row As DataRow In input
output.ImportRow(row)
Next

Hope this helps
Jay
"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Yeah I found a C# Example about it that that sucked, but I got the idea and made this!

Dim myTable As DataTable = dvCodes.Table.Clone

Dim enumCodes As IEnumerator = dvCodes.GetEnumerator

While enumCodes.MoveNext

Dim myRowView As DataRowView = enumCodes.Current

Dim newRow As DataRow = myTable.NewRow

Try

newRow("CREG_ID") = myRowView("creg_ID")

newRow("creg_regType") = myRowView("creg_regType")

newRow("creg_code") = myRowView("creg_code")

newRow("creg_text") = myRowView("creg_text")

newRow("creg_catId") = myRowView("creg_catId")

newRow("creg_unit") = myRowView("creg_unit")

myTable.Rows.Add(newRow)

Catch ex As Exception

MsgBox(ex.Message)

End Try

End While

/Lars


"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> skrev i
meddelandet news:Om**************@TK2MSFTNGP09.phx.gbl...
I think you will have to iterate through the rows and add them to a table.
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:OP**************@tk2msftngp13.phx.gbl...
I have a Dataview with a rowfilter on and I want to create a DataTable

from
that filtering!

It's because I need to set that Table as a property in a special class

that
I have.. and I can't change the class to use Dataviews instead so I
need to
do this

best regard
/lars



Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jim Heimer | last post by:
When I use the dataview.rowfilter and I try to display the field value of the first row, the code doesn't seem to show the first row AFTER the rowfilter. This is my code: DataView...
2
by: Jensen bredal | last post by:
Hello, I use The RowFilter property to select number of row from my dataview. How can i get the number of rows found ? I experience that the number of rows remains the same as before the...
3
by: Vern | last post by:
The following code retrieves data into a dataset, and then creates a dataview with a filter. This dataview is then attached to a combobox. When the effective date changes, I would like to see the...
2
by: Ryan Moore | last post by:
I have a dataset (called adset) which has a column called "Large" which is either an integer 0 or 1. I am creating 2 dataviews, one which should display the 1's and one which should display the...
8
by: Dave Hagerich | last post by:
I'm using a DataGrid with a DataSet and I'm trying to filter the data being displayed, using the following code as a test: DataView theView = new DataView(theDataSet.Tables); theView.RowFilter =...
13
by: Steve | last post by:
I have a form with a dataset and a datagrid. I created a dataview on this dataset. When the user modifies the datagrid, I look up this record in the dataview to make sure it is unique. Here is...
7
by: Rich | last post by:
Hello, I am pulling master data from one master table and detail data from two detail tables. The rows from the master data are displayed in textboxes on my form which are bound to the data...
7
by: randy1200 | last post by:
I have an orders table. Each record in the orders table contains a customer id. I have a customer table. The primary key of each record in the customer table is the customer id. After getting...
3
by: =?Utf-8?B?cG1jZ3VpcmU=?= | last post by:
I have a dataset with 3 tables -- 2 Parent tables and 1 table that is a child table of both the parents. I create a dataview on the child table and set the rowfilter to a value which filters the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.