473,395 Members | 1,456 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,395 software developers and data experts.

Passing a Datavie to a Subroutine

I want to pass a dataview to another subroutine. I've successfully created
the datavew as follows:

For Each CriteriaDetailRow In AlertData.AlertDS.Tables("EventCriteria").Rows

Dim foundRows() As DataRowView = Min_NumView.FindRows(New
Object() {CriteriaDetailRow.Item("Min_Num")})

For Each MinGPSHistoryDetailRow In foundRows

I now want to pass "foundRows" to a subroutine for futher processing as
follows:

NoActivity(foundRows)

The foundRows collection has rows and columns that I need to access. I
defined the function call as follows:

Function NoActivity(InputData)

I'm receiving the collection as follows:

dim GoodData as Array = InputData
I realize that I need to use "For each in GoodData" to read thru the array.

But how do I access the columns of data that I also need? The collection is
results of a datatable.
Thanks
Nov 21 '05 #1
1 1520
Larry,
But how do I access the columns of data that I also need? The collection
is
results of a datatable. Do you want to know what columns are available (DataTable.Columns
collection) or do you want to know you to get the value of a specific
column?

If you want to know what columns are available (DataTable.Columns
collection):

You have two options. Explicitly pass the DataTable that the rows are coming
from.

NoActivity(foundRows, Min_NumView.Table)

Or implicitly retrieve the DataTable from the rows passed.
Function NoActivity(InputData() As DataRowView) Dim table As DataTable = InputData(0).Row.Table
- or -
Dim table As DataTable = InputData(0).DataView.Table

Once you have the DataTable, you can use its Columns collection to get what
columns are available.

I would recommend you avoid using Array directly instead defining the array
for the type it really is:

dim GoodData() as DataRowView = InputData

Or better yet, simple define the InputData parameter as an array of
DataRowView:
Function NoActivity(InputData() as DataRowView)
I would also recommend that you put "Option Strict On" at the top of each of
your source files, as this will identify some errors at compile time, rather
then leaving them for hard to find errors at runtime.

Once you have properly defined variables (DataRowView() instead of Array)
you can simply use

Sub NoActivity(inputData() as DataRowView)
For each row As DataRowView In inputData
dim id As Integer = row("column1")
Next
End Sub

If you don't have it I would strongly recommend you purchase David Sceppa's
"Microsoft ADO.NET" from MS Press is a good Desk Reference for ADO.NET, it
provides a lot of useful information on getting performance out of data
adapters & datasets.

Hope this helps
Jay

"Larry Bird" <La*******@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...I want to pass a dataview to another subroutine. I've successfully created
the datavew as follows:

For Each CriteriaDetailRow In
AlertData.AlertDS.Tables("EventCriteria").Rows

Dim foundRows() As DataRowView = Min_NumView.FindRows(New
Object() {CriteriaDetailRow.Item("Min_Num")})

For Each MinGPSHistoryDetailRow In foundRows

I now want to pass "foundRows" to a subroutine for futher processing as
follows:

NoActivity(foundRows)

The foundRows collection has rows and columns that I need to access. I
defined the function call as follows:

Function NoActivity(InputData)

I'm receiving the collection as follows:

dim GoodData as Array = InputData
I realize that I need to use "For each in GoodData" to read thru the
array.

But how do I access the columns of data that I also need? The collection
is
results of a datatable.
Thanks

Nov 21 '05 #2

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

Similar topics

6
by: Adrian | last post by:
I am trying to pass the address of a C++ function into a Fortran routine to enable the Fortran routine to call this C++ function. I have to do it this way as our build process does not allow...
1
by: Sam | last post by:
Hello all I have a two dimensional array (the dimensions are not known) that needs to be passed to fortran from c++, allocate the dimensions of the array in fortran code, do some filling up of...
3
by: Scott | last post by:
What is the proper syntax for sending an argument from a form contol to a subroutine in a module? For instance, from a textbox on a form I call a module subroutine from the textbox's OnUpdate...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
7
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a...
3
by: Stephen Travis | last post by:
I'm trying to write a subroutine that will fill an array of some type with several objects of that type. The subroutine works fine if I directly reference the array but if I pass the array as an...
2
by: Mark Drummond | last post by:
Hi all. I've been using Perl for many years now, but I am a "use it and learn it as you need it" type. I having some trouble passing a list to the "search" subroutine from Net::LDAP. I am trying...
2
by: mj.redfox.mj | last post by:
Hi, Pretty basic question, apologies but being a bit of a newbie I still don't know the answer to this kind of thing! I have a repeater which, upon databind calls a subroutine, as below: ...
2
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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...

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.