HighTechTalks DotNet Forums  

DataRow Array size

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss DataRow Array size in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
=?Utf-8?B?TWFuanJlZSBHYXJn?=
 
Posts: n/a

Default DataRow Array size - 08-28-2007 , 10:42 AM






Hi
Is there any way of declaring an array of DataRow of variable size (or
dynamic array) in ADO.net as the fowwing syntax require the size of the array.

array<DataRow^>^ rows= gcnew array<DataRow^>(size);

I am searching my SQL Server2005 databases DataTable for a given column
value using DataTable::Select method and I don't know how many rows will it
return depending on the selection criteria.

Thanks for any help.

Manjree

Reply With Quote
  #2  
Old   
Cor Ligthert[MVP]
 
Posts: n/a

Default Re: DataRow Array size - 08-28-2007 , 12:40 PM






DataTable is the standard object as collection for datarows.

Trying to set a DataTable in another array is a little bit impossible
because the DataRow needs is companion collection The DataColumns, which is
also part of the datatable.

Cor

"Manjree Garg" <garg (AT) newsgroup (DOT) nospam> schreef in bericht
news:12A5F6FA-E2CE-460F-B75D-525FE3DE7BA0 (AT) microsoft (DOT) com...
Quote:
Hi
Is there any way of declaring an array of DataRow of variable size (or
dynamic array) in ADO.net as the fowwing syntax require the size of the
array.

array<DataRow^>^ rows= gcnew array<DataRow^>(size);

I am searching my SQL Server2005 databases DataTable for a given column
value using DataTable::Select method and I don't know how many rows will
it
return depending on the selection criteria.

Thanks for any help.

Manjree


Reply With Quote
  #3  
Old   
WenYuan Wang [MSFT]
 
Posts: n/a

Default RE: DataRow Array size - 08-29-2007 , 04:44 AM



Hello Manjree,
Thanks for Cor's help.

In general, DataTable is a collection for datarows.

For you case, have you tried the following line?
array<System:ata:ataRow^>^ rows=myTable->Select("...");

In my opinion, we need not to define the size for array. Table::Select
method will return the array for us.

Hope this helps.
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #4  
Old   
=?Utf-8?B?TWFuanJlZSBHYXJn?=
 
Posts: n/a

Default Re: DataRow Array size - 08-29-2007 , 07:24 AM



Hi Wen

I am still looking for the resolutio of my problem "How to store rows
returned by a selection criteria as the no. of rows returned are not fixed?"

I really appriciate your help.

Thanks.

Manjree

"Cor Ligthert[MVP]" wrote:

Quote:
DataTable is the standard object as collection for datarows.

Trying to set a DataTable in another array is a little bit impossible
because the DataRow needs is companion collection The DataColumns, which is
also part of the datatable.

Cor

"Manjree Garg" <garg (AT) newsgroup (DOT) nospam> schreef in bericht
news:12A5F6FA-E2CE-460F-B75D-525FE3DE7BA0 (AT) microsoft (DOT) com...
Hi
Is there any way of declaring an array of DataRow of variable size (or
dynamic array) in ADO.net as the fowwing syntax require the size of the
array.

array<DataRow^>^ rows= gcnew array<DataRow^>(size);

I am searching my SQL Server2005 databases DataTable for a given column
value using DataTable::Select method and I don't know how many rows will
it
return depending on the selection criteria.

Thanks for any help.

Manjree


Reply With Quote
  #5  
Old   
Cor Ligthert[MVP]
 
Posts: n/a

Default Re: DataRow Array size - 08-29-2007 , 01:25 PM



Manjree,

The rows are forever fixed even when they are in a collection, they belong
to a datatable.

See for that the property DataRow.Table

Cor

"Manjree Garg" <garg (AT) newsgroup (DOT) nospam> schreef in bericht
news:163302C6-10D4-4883-8654-826596D19B29 (AT) microsoft (DOT) com...
Quote:
Hi Wen

I am still looking for the resolutio of my problem "How to store rows
returned by a selection criteria as the no. of rows returned are not
fixed?"

I really appriciate your help.

Thanks.

Manjree

"Cor Ligthert[MVP]" wrote:

DataTable is the standard object as collection for datarows.

Trying to set a DataTable in another array is a little bit impossible
because the DataRow needs is companion collection The DataColumns, which
is
also part of the datatable.

Cor

"Manjree Garg" <garg (AT) newsgroup (DOT) nospam> schreef in bericht
news:12A5F6FA-E2CE-460F-B75D-525FE3DE7BA0 (AT) microsoft (DOT) com...
Hi
Is there any way of declaring an array of DataRow of variable size (or
dynamic array) in ADO.net as the fowwing syntax require the size of the
array.

array<DataRow^>^ rows= gcnew array<DataRow^>(size);

I am searching my SQL Server2005 databases DataTable for a given column
value using DataTable::Select method and I don't know how many rows
will
it
return depending on the selection criteria.

Thanks for any help.

Manjree



Reply With Quote
  #6  
Old   
WenYuan Wang [MSFT]
 
Posts: n/a

Default Re: DataRow Array size - 08-30-2007 , 03:12 AM



Hello Manjree,

Just as what Cor said, the Property Table->Rows->Count will return the
number of rows in current Table.
If rows retruned by Table::Select() method, Table->Select()->Length
proptery could tell us how many rows retruned by this selection criteria.

Try the following line:
array<System:ata:ataRow^>^ rows=gcnew
array<System:ata:ataRow^>(MyTable->Select("ID>100")->Length);
rows=MyTable->Select("ID>100");

Hope this helps. Please let me know if you have any more concern. It's my
pleasure to assist you. Have a great day.
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #7  
Old   
=?Utf-8?B?TWFuanJlZSBHYXJn?=
 
Posts: n/a

Default Re: DataRow Array size - 08-31-2007 , 09:28 AM



Hi Wen

I am trying the following code:

pSrchRows=gcnew array<DataRow^>((pSrchTable1->Select(L"pSrchColumn1= 'aaa'
"))->Length);

pSrchRows=(pSrchTable1->Select(L"pSrchColumn1 = 'aaa' "));

which is throwing System.Data.EvaluateException.
cannot find column [pSrchColumn1]

Though I've checked it is taking correct table (say Supplier) in pSrchTable1
and correct column (e.g. supplierID) in pSrchColumn1 and there is a record
with value supplierID = 'aaa' in the database.


Any help will be appriciated.

Thanks.
Manjree




"WenYuan Wang [MSFT]" wrote:

Quote:
Hello Manjree,

Just as what Cor said, the Property Table->Rows->Count will return the
number of rows in current Table.
If rows retruned by Table::Select() method, Table->Select()->Length
proptery could tell us how many rows retruned by this selection criteria.

Try the following line:
array<System:ata:ataRow^>^ rows=gcnew
array<System:ata:ataRow^>(MyTable->Select("ID>100")->Length);
rows=MyTable->Select("ID>100");

Hope this helps. Please let me know if you have any more concern. It's my
pleasure to assist you. Have a great day.
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



Reply With Quote
  #8  
Old   
WenYuan Wang [MSFT]
 
Posts: n/a

Default Re: DataRow Array size - 09-02-2007 , 11:18 PM



Hello Manjree,

Try the following code line.
pSrchRows=gcnew array<DataRow^>((pSrchTable1->Select(L"supplierID = 'aaa'
"))->Length);

The column in the filter criteria should be the name of Column (supplierID)
rather than the name of object (pSrchColumn1).

http://msdn2.microsoft.com/en-us/library/det4aw50.aspx
[DataTable.Select Method (String)]

Hope this help. Please let me know if this works for you. I will follow up.
It's my pleasure to assist you.
Have a great day.
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #9  
Old   
=?Utf-8?B?TWFuanJlZSBHYXJn?=
 
Posts: n/a

Default Re: DataRow Array size - 09-03-2007 , 05:38 AM



Hello Wen

Thanks for the reply. It did work.

But the problem is that search can be on any column of any table selected
from comboBoxes in the GUI. So I set pSrchColumn1 to the selected column and
then use it.
Is there any other way round to resolve this problem?

Thanks.

Manjree

"WenYuan Wang [MSFT]" wrote:

Quote:
Hello Manjree,

Try the following code line.
pSrchRows=gcnew array<DataRow^>((pSrchTable1->Select(L"supplierID = 'aaa'
"))->Length);

The column in the filter criteria should be the name of Column (supplierID)
rather than the name of object (pSrchColumn1).

http://msdn2.microsoft.com/en-us/library/det4aw50.aspx
[DataTable.Select Method (String)]

Hope this help. Please let me know if this works for you. I will follow up.
It's my pleasure to assist you.
Have a great day.
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



Reply With Quote
  #10  
Old   
WenYuan Wang [MSFT]
 
Posts: n/a

Default Re: DataRow Array size - 09-03-2007 , 08:14 AM



Hello Tomasz,
Thanks for your reply.

http://msdn2.microsoft.com/en-us/lib...n.columnname(V
S.80).aspx
[DataColumn.ColumnName Property]

DataColumn.columnName property returns the name of current DataColumn
object.

Please try the following method and let me know if this is what you need.
I'm glad to assist you.

pSrchRows=gcnew array<DataRow^>((pSrchTable1->Select( pSrchColumn1->
columnName + L" = 'aaa' ")->Length);

Hope this helps.
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.