Hi
Suppose we have an array of DataRows e.g.
Dim drMyRows() As DataRow = myTable.Rows(0) .GetChildRows(" PricesCompany")
generated via a relationship.
The question I have is this. Isn't this in essence a table i.e. a collection
of rows? The reason I ask is that I wanted to extract from the array of rows
certain rows satisfying a given condition. Now, if this had been a
DataTable, I could have done something like:
Dim strCriteria As String = "Prices = '2' AND Company = 'ABC Ltd'"
Dim strSortOrder As String = "Town DESC"
Dim aRows As DataRow() myNewTable.Sele ct(strCriteria, strSortOrder)
Is there a way of doing this with the array of rows? Ok, I suppose I could
create a new table using the array of rows but this will surely increase the
amount of processing. Is there an easier and more efficient way to do this?
Thanks in advance
Geoff 5 1671
Hi Geoff,
When you have the datarow(0) you know probably as well the criteria to use
in your related table for a dataview. Why do you not use that, looks for me
a lot simpler.
(I was first busy to tell you that when you go this way you can make a
datatable by cloning the related table and than use the importrow in a for
each loop, however thinking about that, it did look for me the wrong way)
Cor Suppose we have an array of DataRows e.g.
Dim drMyRows() As DataRow = myTable.Rows(0) .GetChildRows(" PricesCompany")
generated via a relationship.
The question I have is this. Isn't this in essence a table i.e. a
collection of rows? The reason I ask is that I wanted to extract from the array of
rows certain rows satisfying a given condition. Now, if this had been a DataTable, I could have done something like:
Dim strCriteria As String = "Prices = '2' AND Company = 'ABC Ltd'" Dim strSortOrder As String = "Town DESC"
Dim aRows As DataRow() myNewTable.Sele ct(strCriteria, strSortOrder)
Is there a way of doing this with the array of rows? Ok, I suppose I could create a new table using the array of rows but this will surely increase
the amount of processing. Is there an easier and more efficient way to do
this? Thanks in advance
Geoff
Geoff, The question I have is this. Isn't this in essence a table i.e. a
collection of rows?
Yes its a collection of Rows, however a Table is significantly more then a
collection of Rows, as evidenced by the Methods, Properties, and Events
unique to a DataTable, that System.Array does not have.
Is there a way of doing this with the array of rows?
No! As you are finding you, an Array has no special powers. System.Array has
a couple shared methods that may help, however if I were using the DataSet
object model, I would attempt to stay with the DataSet OM.
Ok, I suppose I could create a new table using the array of rows but this will surely increase
the amount of processing. Is there an easier and more efficient way to do
this?
I would consider leaving them in the original DataTable, before I decided
copying them into a new DataTable, as copying them to a new DataTable will
do just that, create a copy of the rows. If you leave them in the Array or
DataView, then the rows themselves are still part of the original DataTable,
the array & DataView only have references to these original rows. Read a new
DataTable introduces aliasing problems, which you may be able to solve with
DataSet.Merge.
Depending on what I needed to do with the "extract" of the ChildRows, I
would probably simply use a For Each on the ChildRows, checking each for the
specific criteria.
Dim drMyRows() As DataRow = myTable.Rows(0) .GetChildRows(" PricesCompany")
For Each row As DataRow in drMyRows
If row!Prices = 2 Then
' do something exciting with this row.
End If
Next
Hope this helps
Jay
"Geoff Jones" <ge***@NODAMNSP AM.com> wrote in message
news:40******** *************** @news.dial.pipe x.com... Hi
Suppose we have an array of DataRows e.g.
Dim drMyRows() As DataRow = myTable.Rows(0) .GetChildRows(" PricesCompany")
generated via a relationship.
The question I have is this. Isn't this in essence a table i.e. a
collection of rows? The reason I ask is that I wanted to extract from the array of
rows certain rows satisfying a given condition. Now, if this had been a DataTable, I could have done something like:
Dim strCriteria As String = "Prices = '2' AND Company = 'ABC Ltd'" Dim strSortOrder As String = "Town DESC"
Dim aRows As DataRow() myNewTable.Sele ct(strCriteria, strSortOrder)
Is there a way of doing this with the array of rows? Ok, I suppose I could create a new table using the array of rows but this will surely increase
the amount of processing. Is there an easier and more efficient way to do
this? Thanks in advance
Geoff
Many thanks Jay for your help.
Geoff
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:u1******** ******@TK2MSFTN GP12.phx.gbl... Geoff, The question I have is this. Isn't this in essence a table i.e. a collection of rows? Yes its a collection of Rows, however a Table is significantly more then a collection of Rows, as evidenced by the Methods, Properties, and Events unique to a DataTable, that System.Array does not have.
Is there a way of doing this with the array of rows? No! As you are finding you, an Array has no special powers. System.Array
has a couple shared methods that may help, however if I were using the DataSet object model, I would attempt to stay with the DataSet OM.
Ok, I suppose I could create a new table using the array of rows but this will surely increase the amount of processing. Is there an easier and more efficient way to do this? I would consider leaving them in the original DataTable, before I decided copying them into a new DataTable, as copying them to a new DataTable will do just that, create a copy of the rows. If you leave them in the Array or DataView, then the rows themselves are still part of the original
DataTable, the array & DataView only have references to these original rows. Read a
new DataTable introduces aliasing problems, which you may be able to solve
with DataSet.Merge.
Depending on what I needed to do with the "extract" of the ChildRows, I would probably simply use a For Each on the ChildRows, checking each for
the specific criteria.
Dim drMyRows() As DataRow =
myTable.Rows(0) .GetChildRows(" PricesCompany") For Each row As DataRow in drMyRows If row!Prices = 2 Then ' do something exciting with this row. End If Next
Hope this helps Jay
"Geoff Jones" <ge***@NODAMNSP AM.com> wrote in message news:40******** *************** @news.dial.pipe x.com... Hi
Suppose we have an array of DataRows e.g.
Dim drMyRows() As DataRow =
myTable.Rows(0) .GetChildRows(" PricesCompany") generated via a relationship.
The question I have is this. Isn't this in essence a table i.e. a collection of rows? The reason I ask is that I wanted to extract from the array of rows certain rows satisfying a given condition. Now, if this had been a DataTable, I could have done something like:
Dim strCriteria As String = "Prices = '2' AND Company = 'ABC Ltd'" Dim strSortOrder As String = "Town DESC"
Dim aRows As DataRow() myNewTable.Sele ct(strCriteria, strSortOrder)
Is there a way of doing this with the array of rows? Ok, I suppose I
could create a new table using the array of rows but this will surely increase the amount of processing. Is there an easier and more efficient way to do this? Thanks in advance
Geoff
Hi Geoff,
I am always interrested what is wrong with my answer?
Cor
Geoff,
Rereading Cor's post, I believe DataRowView.Cre ateDataView will actually do
what you want...
Something like:
Dim view As New DataView(myTabl e)
For Each parent As DataRowView In view
Dim prices As DataView = parent.CreateCh ildView("Prices Company")
prices.RowFilte r = "Prices = '2'"
For Each price As DataRowView In prices
Debug.WriteLine (price!Prices, "Prices")
Debug.WriteLine (price!Company, "Company")
Next
Next
I tested the following in VS.NET 2003, with data from the SQL Server
Northwind sample database:
Dim view As New DataView(custom erDataSet.Table s("Customers" ))
For Each customer As DataRowView In view
Dim orders As DataView =
customer.Create ChildView("Cust omerOrders")
orders.RowFilte r = "OrderDate = #2/26/1998#"
For Each order As DataRowView In orders
Debug.WriteLine (order!Customer ID, "CustomerID ")
Debug.WriteLine (order!OrderId, "Order")
Next
Next
The customer.Create ChildView("Cust omerOrders") returns a special DataView
that only has the rows of the child rows available, the RowFilter is in
addition to the relationship...
Hope this helps
Jay
"Geoff Jones" <ge***@NODAMNSP AM.com> wrote in message
news:40******** *************** @news.dial.pipe x.com... Hi
Suppose we have an array of DataRows e.g.
Dim drMyRows() As DataRow = myTable.Rows(0) .GetChildRows(" PricesCompany")
generated via a relationship.
The question I have is this. Isn't this in essence a table i.e. a
collection of rows? The reason I ask is that I wanted to extract from the array of
rows certain rows satisfying a given condition. Now, if this had been a DataTable, I could have done something like:
Dim strCriteria As String = "Prices = '2' AND Company = 'ABC Ltd'" Dim strSortOrder As String = "Town DESC"
Dim aRows As DataRow() myNewTable.Sele ct(strCriteria, strSortOrder)
Is there a way of doing this with the array of rows? Ok, I suppose I could create a new table using the array of rows but this will surely increase
the amount of processing. Is there an easier and more efficient way to do
this? Thanks in advance
Geoff
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 the array in fortran and then accessing it in my c++ code.
Say in my c++ code I have;
extern "C" { void foo_(float **, int &, int &); }
|
by: laclac01 |
last post by:
Is there a way to pass a 2d array to a function in c++ with out having
to specifiy the number of elements in the array. Here is an example
#include<iostream>
using namespace std;
int main()
{
int array;
|
by: Ovid |
last post by:
Hi all,
I'm having a problem trying to create a 2D array whose dimensions are
determined at runtime. Below my signoff is a minimal test case that
hopefully demonstrates what I'm trying to do. Unfortunately, this
segfaults. The output is the following:
$ gcc -Wall -c arrays.c
$ gcc -o arrays arrays.o
$ ./arrays
|
by: Betty Hickman |
last post by:
I'm having trouble writing a 2D array to a binary file. Here's what I
have:
FILE *outfile;
short **clump_class;
clump_class = malloc(nrows * sizeof(short *));
for (i=0; i<nrows; ++i)
clump_class = calloc (ncolumns, sizeof(short *));
|
by: Peace |
last post by:
I am having trouble writing code to turn an array into a delimited string.
Dim splitout As String
splitout = Join(DataArray(rows, columns), " ")
rows and columns are integers representing rows and columns quanitity of
datasets.
Could someone help show what I am doing wrong?
When ever I write splitout to to a text file nothing is there.
| |
by: Eric Lilja |
last post by:
Assignment: Create a 3x4 2-dimensional array of integers. Populate each
element using some non-random scheme so that no two elemens contain the
same value. Then create two functions for printing the 2D array. One
should only work for set column size, accepting only the number of rows
as an additional argument, one should accept both the number...
|
by: Karl Groves |
last post by:
I'm missing something very obvious, but it is getting late and I've
stared at it too long.
TIA for responses
I am writing a basic function (listed at the bottom of this post) that
returns data from a query into an array.
The intent is that the following code:
|
by: gihope |
last post by:
Can anyone tell me why I am not allowed to bind a two or multi dimensional array to GridView and possibly suggest how they would deal with similar scenarios?
The array is simply a two dimensional monthly volume array:
Extract from Report class:
// Query all Messages Sent for a Given Month
public string qVolumeByMonth()
{
...
|
by: vippstar |
last post by:
The subject might be misleading.
Regardless, is this code valid:
#include <stdio.h>
void f(double *p, size_t size) { while(size--) printf("%f\n", *p++); }
int main(void) {
double array = { { 3.14 }, { 42.6 } };
f((double *)array, sizeof array / sizeof **array);
return 0;
|
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...
|
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...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
| |
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...
| |