New array of dataRow[]

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
Hi,

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

what are you trying to do anyway?
 
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 ) said:
Hi,

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

what are you trying to do anyway?


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Niron kag said:
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.
 
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 said:
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 ) said:
Hi,

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

what are you trying to do anyway?


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Niron kag said:
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.
 
Do you think it is simple and better way?

Ignacio Machin ( .NET/ C# MVP ) said:
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 said:
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 ) said:
Hi,

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

what are you trying to do anyway?


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

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.
 
Yape, you should use dataset and datatable. One of the resources:
http://msdn2.microsoft.com/en-us/library/system.data.datatable.dataset(d=ide).aspx

chanmm

Niron kag said:
Do you think it is simple and better way?

Ignacio Machin ( .NET/ C# MVP ) said:
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 said:
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.

:

Hi,

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

what are you trying to do anyway?


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

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.
 
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
 
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 said:
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 said:
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.
 
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 said:
Do you think it is simple and better way?

Ignacio Machin ( .NET/ C# MVP ) said:
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 said:
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.

:

Hi,

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

what are you trying to do anyway?


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

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.
 
Back
Top