PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

DataRow Array size

 
 
=?Utf-8?B?TWFuanJlZSBHYXJn?=
Guest
Posts: n/a
 
      28th Aug 2007
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
 
 
 
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      28th Aug 2007
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" <(E-Mail Removed)> schreef in bericht
news:12A5F6FA-E2CE-460F-B75D-(E-Mail Removed)...
> 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
 
WenYuan Wang [MSFT]
Guest
Posts: n/a
 
      29th Aug 2007
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
 
=?Utf-8?B?TWFuanJlZSBHYXJn?=
Guest
Posts: n/a
 
      29th Aug 2007
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" <(E-Mail Removed)> schreef in bericht
> news:12A5F6FA-E2CE-460F-B75D-(E-Mail Removed)...
> > 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
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      29th Aug 2007
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" <(E-Mail Removed)> schreef in bericht
news:163302C6-10D4-4883-8654-(E-Mail Removed)...
> 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" <(E-Mail Removed)> schreef in bericht
>> news:12A5F6FA-E2CE-460F-B75D-(E-Mail Removed)...
>> > 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
 
WenYuan Wang [MSFT]
Guest
Posts: n/a
 
      30th Aug 2007
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
 
=?Utf-8?B?TWFuanJlZSBHYXJn?=
Guest
Posts: n/a
 
      31st Aug 2007
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:

> 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
 
WenYuan Wang [MSFT]
Guest
Posts: n/a
 
      3rd Sep 2007
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
 
=?Utf-8?B?TWFuanJlZSBHYXJn?=
Guest
Posts: n/a
 
      3rd Sep 2007
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:

> 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
 
WenYuan Wang [MSFT]
Guest
Posts: n/a
 
      3rd Sep 2007
Hello Tomasz,
Thanks for your reply.

http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.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
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New array of dataRow[] =?Utf-8?B?Tmlyb24ga2Fn?= Microsoft C# .NET 8 18th Jul 2006 01:50 PM
How to remove a row of a Datarow()-Array lvpaul@gmx.net Microsoft ADO .NET 2 17th Jan 2006 10:32 AM
How declare array of DataRow =?Utf-8?B?UGV0ZXo=?= Microsoft VC .NET 2 3rd Feb 2005 11:33 PM
row count in datarow[] array Microsoft C# .NET 1 14th Mar 2004 01:55 PM
Help with searching DataRow array... =?Utf-8?B?Q2FybG9zIEs=?= Microsoft VB .NET 2 14th Jan 2004 05:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:53 AM.