473,624 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return DataRow

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

Aug 31 '06 #1
5 11671
Duh! What I am trying to say is that I need to return the foundRows as
an object.

samoore33 wrote:
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
Aug 31 '06 #2
samoore33 wrote:
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)

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 not sure how to return the foundRows information.
foundRows is an array of DataRows, so return that from your function, as
in:

Function XYZ(ByVal result As DataSet) As DataRow()
Dim t As DataTable
= result.Tables(" State")
Dim strExpr As String _
= "id = '" & theState.ToStri ng() & "'"
Dim foundRows() As DataRow _
= t.Select(strExp r)

Return foundRows
End Function

HTH,
Phill W.
Aug 31 '06 #3
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

Aug 31 '06 #4
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
Aug 31 '06 #5
See two changed lines in code below (maked: --- Was ...). Now the function
returns an ojtect that is an array of DataRows.

But perhaps you want to put the returned rows into a DataTable and return
that?
Public Function SearchXML(ByVal theState As String) As DataRow() --- WAS
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 foundRows --- WAS result

End Function

--
Mike

Mike McIntyre [MVP]
http://www.getdotnetcode.com
"samoore33" <sa*******@gmai l.comwrote in message
news:11******** *************@e 3g2000cwe.googl egroups.com...
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(foun dRows)
....

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******* **************@ h48g2000cwc.goo glegroups.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

Sep 2 '06 #6

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

Similar topics

3
1767
by: Phil | last post by:
Hi, I have a client/server app. that uses a windows service for the server and asp.net web pages for the client side. My server class has 3 methods that Fill, Add a new record and Update a record. The Fill and Add routines work as expected but unfortunately the update request falls at the 1st hurdle. I pass two params to the remote(server) method for the update, one is the unique ID and the other is a string that is the name of the table...
2
2401
by: vbMark | last post by:
When I call the below code what I get returned is the string "System.Data.DataRow" I don't understand how this works. What am I doing wrong? private string GetData(string strQuery) { SqlConnection sqlCN = new SqlConnection(CONNECTION_INFO); SqlDataAdapter sqlDA = new SqlDataAdapter(strQuery, sqlCN);
0
1784
by: Ron Vecchi | last post by:
I am using the Select method on a DataTable to return a DataRow filter = (width LIKE '%width=\"%') I am getting an exception saying my filter is invalid I narrowed it down to the part that reads if I eliminate this part it works. Is there a way to accomplish what I'm tring to do?
4
2887
by: Michael Carr | last post by:
I have a function that populates a class with values from a database. I'd like to pass into the function either a SqlDataReader or a DataRow, depending on which mechanism I'm using to retrieve data from the database. However, the two classes don't appear to have any common interfaces that would allow me to enumerate the fields. Yet, when you databind you can pass either of these classes (as well as many others) and .NET somehow knows how...
4
2006
by: CaptRR | last post by:
I think this is the right group to post to, so here goes. My problem is this, I cannot update the datarow to save my life. Been on this for 2 days now, and still am no closer to figuring it out than I was before. I'm basicly taking date from some text boxes, trying to put them into a datarow and using that datarow to update the database, but its not working. The btn_update is where I am sending the information back to the addclient...
3
1574
by: News | last post by:
Hi, I wrote a function that pulls a record, below: ++++++++++++++++++++++++++++++++++++++++ Public Function getServPlanProgActivity( serviceprogramenroll_id As Integer, activity_id As Integer ) As DataRow ' Connect To db Dim myConn As New SqlConnection(_DSN) Dim dtrHasRows As DataRow Try
11
27424
by: Tim Frawley | last post by:
I need to return a DataRow or the Row Index in a DataSet wherein the value I am attempting to find is not a primary key. I have to do this often, more than 200 times when importing a file so it needs to be fast. Could I use a Dataview to filter for the value (which is unique) and return either the DataRow object so I can modify it and put it back into the DataSet the view is based on or somehow get the RowIndex in the DataSet that the...
6
1631
by: JIM.H. | last post by:
Hello I have; DataRow dr= dataSet11.myTable.NewRow(); And I am filling the fields of this datarow. Now I need to create a copy of this row as drCopy and change a few fields and add both to the dataset, how can I do this? Thanks,
10
24167
by: mcbobin | last post by:
Hi, Here's hoping someone can help... I'm using a stored procedure to return a single row of data ie a DataRow e.g. public static DataRow GetManualDailySplits(string prmLocationID, string
0
8233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8170
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8334
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6108
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2604
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.