New array of dataRow[]

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.
 
I

Ignacio Machin \( .NET/ C# MVP \)

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?
 
G

Guest

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.
 
I

Ignacio Machin \( .NET/ C# MVP \)

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.
 
G

Guest

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.
 
C

chanmm

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.
 
G

Guest

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
 
G

Guest

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.
 
I

Ignacio Machin \( .NET/ C# MVP \)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top