Using System.GUID in a RowFilter

G

Guest

I have a table in SQL server that has a column of type UniqueIdentifier. I
use a DataAdapter to fill a typed DataSet with rows from the table.
(Interestingly, when I look at the typed dataset, the datatype of this column
has magically changed to STRING). Anyway, I need to use this column value in
a DataView.RowFilter. However, when I try to create the
RowFilter="ColumnName='" & value & "'" I get a runtime error that says I
there's no operator that will contatenate (&) a STRING and a SYSYEM.GUID.

Apparently, when I fill the typed dataset, the datatype changes to
SYSTEM.GUID (I assume the same as UniqueIdentifier), even though the datatype
in the typed dataset says STRING.

So, how do I use a SYSTEM.GUID in a RowFilter when there doesn't seem to be
a way to convert it into a string?
 
S

Steven Cheng[MSFT]

Hi Michael,

Welcome to MSDN newsgroup.
As for the Guid DataType, it seems that currently the string based select
experssion (or rowFilter ) for the DataTable/DataView haven't provided the
support for Guid Type. I've found someones using the
DataTable.Rows.Find(object) which could take the object paramter as the pk
value to workaround the problem.
So if our datatable use Guid type as the primary key, we can consider using
the DataRowCollection.Find method to query rows.

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.)
 
A

Andrew Conrad

Try converting the GUID to a string before doing the contatenation. i.e.

RowFilter="Convert(ColumnName, 'System.String')='" & value & "'"

Andrew Conrad
Microsoft Corp
 
C

caledh

When I try this, I receive a message that states: Object must use
IConvertable. So, no dice Andrew.
 

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

Top