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

New array of dataRow[]

Hi,
I have a loop an in the loop I populate an array of dataRow.
My problem is the array keeps its values from previous loop, and its Length
gets bigger every loop.
My code is:
DataRow[] foundRowsAct; sSQL ="SQL STATEMENT";
foundRowsAct = dtACTIVITIES.Select(sSQL);

I tried to write in the loop:
foundRowsAct=null;

But it did not help.
What can I do to get a new array every loop?
Thanks in advance.

Jul 17 '06 #1
8 21825
Hi,

If you have a variant number of rows you better use ArrayList or
List<DataRowif possible.

what are you trying to do anyway?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:0C**********************************@microsof t.com...
Hi,
I have a loop an in the loop I populate an array of dataRow.
My problem is the array keeps its values from previous loop, and its
Length
gets bigger every loop.
My code is:
DataRow[] foundRowsAct; sSQL ="SQL STATEMENT";
foundRowsAct = dtACTIVITIES.Select(sSQL);

I tried to write in the loop:
foundRowsAct=null;

But it did not help.
What can I do to get a new array every loop?
Thanks in advance.

Jul 17 '06 #2
Ignacio Machin,
I do a query on dataTable and populate the dataRow[] with the results.
I do it in a “for”, In every loop the dataRow Length get bigger even when I
compare it to null before every loop.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

If you have a variant number of rows you better use ArrayList or
List<DataRowif possible.

what are you trying to do anyway?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:0C**********************************@microsof t.com...
Hi,
I have a loop an in the loop I populate an array of dataRow.
My problem is the array keeps its values from previous loop, and its
Length
gets bigger every loop.
My code is:
DataRow[] foundRowsAct; sSQL ="SQL STATEMENT";
foundRowsAct = dtACTIVITIES.Select(sSQL);

I tried to write in the loop:
foundRowsAct=null;

But it did not help.
What can I do to get a new array every loop?
Thanks in advance.


Jul 17 '06 #3
Hi,

Why dont you use a DataView (as you are using a Datatable ) ?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:33**********************************@microsof t.com...
Ignacio Machin,
I do a query on dataTable and populate the dataRow[] with the results.
I do it in a "for", In every loop the dataRow Length get bigger even when
I
compare it to null before every loop.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
>Hi,

If you have a variant number of rows you better use ArrayList or
List<DataRowif possible.

what are you trying to do anyway?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:0C**********************************@microso ft.com...
Hi,
I have a loop an in the loop I populate an array of dataRow.
My problem is the array keeps its values from previous loop, and its
Length
gets bigger every loop.
My code is:
DataRow[] foundRowsAct; sSQL ="SQL STATEMENT";
foundRowsAct = dtACTIVITIES.Select(sSQL);

I tried to write in the loop:
foundRowsAct=null;

But it did not help.
What can I do to get a new array every loop?
Thanks in advance.



Jul 17 '06 #4
Do you think it is simple and better way?

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Why dont you use a DataView (as you are using a Datatable ) ?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:33**********************************@microsof t.com...
Ignacio Machin,
I do a query on dataTable and populate the dataRow[] with the results.
I do it in a "for", In every loop the dataRow Length get bigger even when
I
compare it to null before every loop.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

If you have a variant number of rows you better use ArrayList or
List<DataRowif possible.

what are you trying to do anyway?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:0C**********************************@microsof t.com...
Hi,
I have a loop an in the loop I populate an array of dataRow.
My problem is the array keeps its values from previous loop, and its
Length
gets bigger every loop.
My code is:
DataRow[] foundRowsAct; sSQL ="SQL STATEMENT";
foundRowsAct = dtACTIVITIES.Select(sSQL);

I tried to write in the loop:
foundRowsAct=null;

But it did not help.
What can I do to get a new array every loop?
Thanks in advance.



Jul 17 '06 #5
Yape, you should use dataset and datatable. One of the resources:
http://msdn2.microsoft.com/en-us/lib...et(d=ide).aspx

chanmm

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:1E**********************************@microsof t.com...
Do you think it is simple and better way?

"Ignacio Machin ( .NET/ C# MVP )" wrote:
>Hi,

Why dont you use a DataView (as you are using a Datatable ) ?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:33**********************************@microso ft.com...
Ignacio Machin,
I do a query on dataTable and populate the dataRow[] with the results.
I do it in a "for", In every loop the dataRow Length get bigger even
when
I
compare it to null before every loop.

"Ignacio Machin ( .NET/ C# MVP )" wrote:

Hi,

If you have a variant number of rows you better use ArrayList or
List<DataRowif possible.

what are you trying to do anyway?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:0C**********************************@microso ft.com...
Hi,
I have a loop an in the loop I populate an array of dataRow.
My problem is the array keeps its values from previous loop, and its
Length
gets bigger every loop.
My code is:
DataRow[] foundRowsAct; sSQL ="SQL STATEMENT";
foundRowsAct = dtACTIVITIES.Select(sSQL);

I tried to write in the loop:
foundRowsAct=null;

But it did not help.
What can I do to get a new array every loop?
Thanks in advance.




Jul 17 '06 #6
If "dtACTIVITIES" is a DataTable, then you are fine doing things just the way
you are. Declare your "foundRowsACT" array outside of (before) the loop and
set it to =null

if your loop is constructed correctly you will be re-assigning the DataRow[]
result of each sSQL query filter to the foundRowsACT DataRow array each time.
Its contents and the number or DataRows in it should be different for each
different sSQL query filter that you apply in your Select method.

If it isn't then you have some other kind of issue going on- e.g., maybe
your filter is no good.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Niron kag" wrote:
Hi,
I have a loop an in the loop I populate an array of dataRow.
My problem is the array keeps its values from previous loop, and its Length
gets bigger every loop.
My code is:
DataRow[] foundRowsAct; sSQL ="SQL STATEMENT";
foundRowsAct = dtACTIVITIES.Select(sSQL);

I tried to write in the loop:
foundRowsAct=null;

But it did not help.
What can I do to get a new array every loop?
Thanks in advance.
Jul 17 '06 #7
Peter Bromberg,
The problem was that the dataTable that I used in the dataTable.select, was
filled in every loop by other data Adapter.
I solve the problem when in the beginning of each loop I wrote dtACTIVITIES
= new DataTable();
"Peter Bromberg [C# MVP]" wrote:
If "dtACTIVITIES" is a DataTable, then you are fine doing things just the way
you are. Declare your "foundRowsACT" array outside of (before) the loop and
set it to =null

if your loop is constructed correctly you will be re-assigning the DataRow[]
result of each sSQL query filter to the foundRowsACT DataRow array each time.
Its contents and the number or DataRows in it should be different for each
different sSQL query filter that you apply in your Select method.

If it isn't then you have some other kind of issue going on- e.g., maybe
your filter is no good.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Niron kag" wrote:
Hi,
I have a loop an in the loop I populate an array of dataRow.
My problem is the array keeps its values from previous loop, and its Length
gets bigger every loop.
My code is:
DataRow[] foundRowsAct; sSQL ="SQL STATEMENT";
foundRowsAct = dtACTIVITIES.Select(sSQL);

I tried to write in the loop:
foundRowsAct=null;

But it did not help.
What can I do to get a new array every loop?
Thanks in advance.
Jul 18 '06 #8
Hi,

Of course, it's the way to go, unless you really need a DataRow[]
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:1E**********************************@microsof t.com...
Do you think it is simple and better way?

"Ignacio Machin ( .NET/ C# MVP )" wrote:
>Hi,

Why dont you use a DataView (as you are using a Datatable ) ?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:33**********************************@microso ft.com...
Ignacio Machin,
I do a query on dataTable and populate the dataRow[] with the results.
I do it in a "for", In every loop the dataRow Length get bigger even
when
I
compare it to null before every loop.

"Ignacio Machin ( .NET/ C# MVP )" wrote:

Hi,

If you have a variant number of rows you better use ArrayList or
List<DataRowif possible.

what are you trying to do anyway?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:0C**********************************@microso ft.com...
Hi,
I have a loop an in the loop I populate an array of dataRow.
My problem is the array keeps its values from previous loop, and its
Length
gets bigger every loop.
My code is:
DataRow[] foundRowsAct; sSQL ="SQL STATEMENT";
foundRowsAct = dtACTIVITIES.Select(sSQL);

I tried to write in the loop:
foundRowsAct=null;

But it did not help.
What can I do to get a new array every loop?
Thanks in advance.




Jul 18 '06 #9

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

Similar topics

1
by: Martin Lindn | last post by:
I got this example written by David J Gottlieb. Which will not compile. I have previously read in the xml doc with myDataSet.ReadXML(Server.MapPath("bills.xml")) Then when i com to this...
2
by: Petez | last post by:
Hi, I want to declare array of System::Data::DataRow but how? With single variable I write System::Data::DataRow^ aRow but statement System::Data::DataRow^ - not works. System::Data::DataRow* ...
2
by: Carlos K | last post by:
Hello I'm having some difficulty searching a set of rows in a DataRow collection.. This is my question What would be an efficient way to search any column of an DataRow array Let me try to...
5
by: Geoff Jones | last post by:
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...
8
by: Joe Rattz | last post by:
Ok, I can't believe what I am seeing. I am sure I do this other places with no problems, but I sure can't here. I have some code that is indexing into the ItemArray in a DataSet's DataRow. I...
5
by: samoore33 | last post by:
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.ToString() & "'" Dim foundRows() As DataRow...
3
by: creator_bob | last post by:
How do I create an array of datarows from a sorted list? I put a bunch of datarows into a sorted list to sort them. Then I got an array of the sorted elements. However, I cannot typecast them. ...
1
by: NiteshR | last post by:
Please Help! Hi, iv been struggling to figure this out for some time now. Im using visual studio 2005(C#). I want to declare an Array (Pre-defined) of datatype 'Datarow'. The code gets a value...
9
by: myotheraccount | last post by:
Hello, Is there a way to convert a DataRow to a StringArray, without looping through all of the items of the DataRow? Basically, I'm trying to get the results of a query and put them into a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
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,...

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.