PC Review


Reply
Thread Tools Rate Thread

dataTable.Compute("Count(GuidCol)", "") generates Exception

 
 
=?Utf-8?B?R2lsZXNU?=
Guest
Posts: n/a
 
      4th Dec 2005
Hi,

I have a datatable that has three columns each of data type Guid. (which I
have just changed from previously being Integers)

In the past I have used :

dataTable.Compute("Count(Col1)", "Col1=5") - which worked fine

Now having changed the data types to Guids I get an exception when I use:

dataTable.Compute("Count(Col1)",
"Col1='00000000-0000-0000-0001-000000000032'")

(also generates exception for:

dataTable.Compute("Count(Col1)", "") - so the problem is not with the
filter expression.

The error is:
Message="Invalid usage of aggregate function Count() and Type: Guid."
Source="System.Data"

Does anyone know how to get this working please?

thanks,

Giles







generates Exception

I would like to use th

Invalid usage of aggregate function Count() and Type: Guid.
 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      5th Dec 2005
Hi Giles,

Welcome to ADO.net newsgroup.
As for the problem on use DataTable's filter functions (compute or Select
methods...) with Guid column, it is actually due to the DataTable's sql
expression engine only support some basic types such as numeric , string
text .... As for Guid, the DataTable's build-in filtering engine can not
support those sql experssion on Guid type column. Currently based on my
testing, one possible means is to use a string type column which contains
the Guid's string text (through Guid.ToString()), we can perform normal
sql filtering operations on string type columns correctly... So I'm not
sure whether using a string column in your DataTable instead of the Guid
column is possible, if not (e.g your datatable is filled by DataAccessing
from backend database...), we may need to implement our own function which
loop the DataTable rows to find the unique row....

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)





--------------------
| Thread-Topic: dataTable.Compute("Count(GuidCol)", "") generates Exception
| thread-index: AcX5B5WxUTxhEULOTXO/wcNtk6nyjA==
| X-WBNR-Posting-Host: 80.3.160.7
| From: =?Utf-8?B?R2lsZXNU?= <(E-Mail Removed)>
| Subject: dataTable.Compute("Count(GuidCol)", "") generates Exception
| Date: Sun, 4 Dec 2005 11:19:02 -0800
| Lines: 40
| Message-ID: <5F0564BE-03E2-47E3-8440-(E-Mail Removed)>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.adonet:117211
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| Hi,
|
| I have a datatable that has three columns each of data type Guid. (which
I
| have just changed from previously being Integers)
|
| In the past I have used :
|
| dataTable.Compute("Count(Col1)", "Col1=5") - which worked fine
|
| Now having changed the data types to Guids I get an exception when I use:
|
| dataTable.Compute("Count(Col1)",
| "Col1='00000000-0000-0000-0001-000000000032'")
|
| (also generates exception for:
|
| dataTable.Compute("Count(Col1)", "") - so the problem is not with the
| filter expression.
|
| The error is:
| Message="Invalid usage of aggregate function Count() and Type: Guid."
| Source="System.Data"
|
| Does anyone know how to get this working please?
|
| thanks,
|
| Giles
|
|
|
|
|
|
|
| generates Exception
|
| I would like to use th
|
| Invalid usage of aggregate function Count() and Type: Guid.
|

 
Reply With Quote
 
=?Utf-8?B?R2lsZXNU?=
Guest
Posts: n/a
 
      5th Dec 2005
Thanks Steven, for the reply,

Is the column paramater in the Count() function actually used for any
purpose? - ie if I set up another column in the table say a string - does the
value of the strings need to be unique or will it still count all the rows if
the strings are the same. - if so why have a parameter?

Is the behaviour with the GUIDs by design - or is it a bug - are there
likley to be any fixes for this?

Cheers,

Giles.

"Steven Cheng[MSFT]" wrote:

> Hi Giles,
>
> Welcome to ADO.net newsgroup.
> As for the problem on use DataTable's filter functions (compute or Select
> methods...) with Guid column, it is actually due to the DataTable's sql
> expression engine only support some basic types such as numeric , string
> text .... As for Guid, the DataTable's build-in filtering engine can not
> support those sql experssion on Guid type column. Currently based on my
> testing, one possible means is to use a string type column which contains
> the Guid's string text (through Guid.ToString()), we can perform normal
> sql filtering operations on string type columns correctly... So I'm not
> sure whether using a string column in your DataTable instead of the Guid
> column is possible, if not (e.g your datatable is filled by DataAccessing
> from backend database...), we may need to implement our own function which
> loop the DataTable rows to find the unique row....
>
> Thanks,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
>
>
>
> --------------------
> | Thread-Topic: dataTable.Compute("Count(GuidCol)", "") generates Exception
> | thread-index: AcX5B5WxUTxhEULOTXO/wcNtk6nyjA==
> | X-WBNR-Posting-Host: 80.3.160.7
> | From: =?Utf-8?B?R2lsZXNU?= <(E-Mail Removed)>
> | Subject: dataTable.Compute("Count(GuidCol)", "") generates Exception
> | Date: Sun, 4 Dec 2005 11:19:02 -0800
> | Lines: 40
> | Message-ID: <5F0564BE-03E2-47E3-8440-(E-Mail Removed)>
> | MIME-Version: 1.0
> | Content-Type: text/plain;
> | charset="Utf-8"
> | Content-Transfer-Encoding: 7bit
> | X-Newsreader: Microsoft CDO for Windows 2000
> | Content-Class: urn:content-classes:message
> | Importance: normal
> | Priority: normal
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> | Newsgroups: microsoft.public.dotnet.framework.adonet
> | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
> | Xref: TK2MSFTNGXA02.phx.gbl
> microsoft.public.dotnet.framework.adonet:117211
> | X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
> |
> | Hi,
> |
> | I have a datatable that has three columns each of data type Guid. (which
> I
> | have just changed from previously being Integers)
> |
> | In the past I have used :
> |
> | dataTable.Compute("Count(Col1)", "Col1=5") - which worked fine
> |
> | Now having changed the data types to Guids I get an exception when I use:
> |
> | dataTable.Compute("Count(Col1)",
> | "Col1='00000000-0000-0000-0001-000000000032'")
> |
> | (also generates exception for:
> |
> | dataTable.Compute("Count(Col1)", "") - so the problem is not with the
> | filter expression.
> |
> | The error is:
> | Message="Invalid usage of aggregate function Count() and Type: Guid."
> | Source="System.Data"
> |
> | Does anyone know how to get this working please?
> |
> | thanks,
> |
> | Giles
> |
> |
> |
> |
> |
> |
> |
> | generates Exception
> |
> | I would like to use th
> |
> | Invalid usage of aggregate function Count() and Type: Guid.
> |
>
>

 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      6th Dec 2005
Hi Giles,

As far as I know, the aggregate functions only support simple data types,
which does not include GUID. If you set up another string column include
the GUID values, it needn't to be unique.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
 
Vasco Veiga [MS]
Guest
Posts: n/a
 
      6th Dec 2005
It is by design.

Guid (System.Guid) columns are stored as objects, and when asked by the
expression evaluator to evaluate the aggregate COUNT they "don't know" how
to do it.

You can use SqlGuid columns (preferred) or add a calculated column that
converts Guid to SqlGuid, and count it.

dt.Columns.Add( "ugly_sqlguidcol_hack"
, typeof( SqlGuid )
, "CONVERT( guidcol,
'System.Data.SqlTypes.SqlGuid' )" );
dt.Compute( "COUNT( ugly_sqlguidcol_hack )" );


--VV [MS]

"Kevin Yu [MSFT]" <v-(E-Mail Removed)> wrote in message
news:cS4%23CAj%(E-Mail Removed)...
> Hi Giles,
>
> As far as I know, the aggregate functions only support simple data types,
> which does not include GUID. If you set up another string column include
> the GUID values, it needn't to be unique.
>
> Kevin Yu
> =======
> "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
Field Names: "LongName", "ShortName", "Code", "Description","Comments" PeteCresswell Microsoft Access 2 25th Feb 2009 11:41 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB Microsoft Excel New Users 7 13th May 2006 10:02 PM
<FORM METHOD="post" onSubmit="return fieldcheck()" name="orientation" action="http://ws-kitty.BU.edu/AT/survey/orientation/script/write.asp" language="JavaScript"> Joeyej Microsoft ASP .NET 0 4th Jun 2004 08:55 PM
Adding Events to Calendar generates "Unhandled Exception" Rich Peat-Hanna Microsoft Outlook Calendar 0 18th Jan 2004 08:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:17 PM.