Search DataRow Array

S

samoore33

I use the code below to return rows matching the state in the theState
variable. I want to know if it is possible to search through the
DataRow that I am returning with the search. I understand that that
creates a DataRow Array.

I searched through group postings and found where Cor had said
something about bulding the DataTable back, not sure what that meant of
if I could use it with this, but any help would be appreciated.

Dim t As DataTable
t = myDataSet.Tables("State")
Dim strExpr As String
strExpr = "id = '" & theState.ToString() & "'"
Dim foundRow() As DataRow
foundRow = t.Select(strExpr)

Dim taxRow() As DataRow
taxRow = myDataSet.Tables("Tax").Select("Taxes_Id = '" & foundRow(0)(3)
& "'")

Scott
 
I

Izzy

I'm a little confused as to what your trying to accomplish. Can you
provide more details as to what your trying to accomplish.
 
S

samoore33

I am using the code I inserted below to search through a DataTable in
my DataSet. When I search through this DataTable, it returns to the
taxRow that I declare as a DataRow.

I want to know if I can search through the results of the taxRow
DataRow. In this DataSet there can be more then one tax value for each
state. For instance...

NY can have one tax value, the minimun dollar amount would be $0 and
the maximum dollar amount would be $100. For that group, the tax value
would be .0643.

Ny can have another tax value, the minimum dollar amount would be
$100.01 and the maximum dollar amount value would be $1000. For that
group, the tax value would be .09342.

When I use the code below to search through the DataSet, I would have
two rows returned for New York in the taxRow. I want to search through
the taxRow DataRow to find certain values that I may need to update.

I hope this helps.

Thanks.

Scott
 
I

Izzy

You could make a duplicate of your Tax table then take the rows you
selected from the first and add then to the duplicate table. Once they
are in there you could do another Table.Select("column = value")

Is this data stored in Sql Server? If so, then you might want to use
Stored Procedures to select the data your looking for.

Hope this helps,
Izzy
 
S

samoore33

I wish it was izzy. This is in an XML doc that I am writing into a
dataset. The user is going to create this XML doc locally on their pc.
 
C

Cor Ligthert [MVP]

Scott

I don't know where I have written to build the table back

However you have more possibilities to create a new datatable from a
filtered other one.

The most simple one is in my idea probably in VB 2005

\\\
Dim t as DataTable = myDataSet.Tables("State")
Dim strExpr as STring = "id = '" & theState.ToString() & "'"
t.rowfilter = strExpr
dim newtable as datatable = t.totable()
///

http://msdn2.microsoft.com/en-us/library/a8ycds2f.aspx

Be aware that this is a new table.

Where your original table comes from is in no way important by the way.

I hope this helps,

Cor
 

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