Thanks Mike, the printing out part I have. I want to pass it as an
object.
I have created a function that searches through the dataset, I want to
pass the information in the foundRows datarow as an object. I am going
to put my code in here:
Public Function SearchXML(ByVal theState As String) As DataSet
result.ReadXml( "test.xml")
Dim returnTable As DataTable
Dim t As DataTable
t = result.Tables(" State")
Dim strExpr As String
strExpr = "id = '" & theState.ToStri ng() & "'"
Dim foundRows() As DataRow
foundRows = t.Select(strExp r) 'Returns items found
'Checks to make sure items were returned
If foundRows.Lengt h = 0 Then
MessageBox.Show ("That state is not in the list", "State
Does Not Exist", MessageBoxButto ns.OK, MessageBoxIcon. Error)
End If
Return result
End Function
I want the result variable to be populated with the datarow foundRows.
Scott Moore
Mike McIntyre wrote:
Here is a code snippet from MSDN. It is a function that takes an array of
DataRows and processes each row to print it. I think it will explain how
you could process your foundRows.
....
foundRows = t.Select(strExp r)
PrintRows(found Rows)
....
Private Sub PrintRows(ByVal rows() As DataRow)
If rows.Length <= 0 Then
Console.WriteLi ne("no rows found")
Exit Sub
End If
Dim row As DataRow
Dim column As DataColumn
For Each row In rows
For Each column In row.Table.Colum ns
Console.Write(" \table {0}", row(column))
Next column
Console.WriteLi ne()
Next row
End Sub
--
Mike
Mike McIntyre [MVP]
http://www.getdotnetcode.com
"samoore33" <sa*******@gmai l.comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
I use the code below to search through a DataSet:
Dim t As DataTable
t = result.Tables(" State")
Dim strExpr As String
strExpr = "id = '" & theState.ToStri ng() & "'"
Dim foundRows() As DataRow
foundRows = t.Select(strExp r)
This of course returns foundRows. My problem is that I need to return
the foundRows so that I can use that DataRow to display the information
that was found. I am terrible at explaining these things.
I originally looped through this and displayed the information in a
textbox. I have not been informed that I just need to return the
information and that it will be displayed outside of the function.
I am not sure how to return the foundRows information.
Any help would be appreciated.
Scott Moore