Groups | Blog | Home
all groups > dotnet ado.net > june 2006 >

dotnet ado.net : How do I compare 2 UniqueIdentifier Guids?


Bmack500
6/7/2006 1:16:25 PM
Hello. I have two databases, both of which store an objectGUID (from a
contact object) in a UniqueIdentifier Column.

How can I search a value picked up in one (using sqlreader) to a value
in the other table? For example, using the following:


"SELECT * FROM table1 Where objectGUID = '" & sqlReader3("guid") & "'"


This just tells me that I cannot compare objects. How do I cast them,
and what is the syntax for the sql command?


Thanks in advance!
Andy
6/7/2006 1:33:56 PM
sql = string.Format( "SELECT * FROM table1 Where objectGUID = '{0}'",
sqlReader3( "guid" ).ToString() );

It may be hard to miss, but there are single quotes ( ' ) around the
{0}.

HTH
Andy

[quoted text, click to view]
Cor Ligthert [MVP]
6/8/2006 12:00:00 AM
Brett,

Probably do you have to create a New Guid from your string

http://msdn2.microsoft.com/en-us/library/system.guid.newguid(VS.80).aspx

I hope this helps,

Cor

"Bmack500" <brett.mack@gmail.com> schreef in bericht
news:1149711385.520781.140990@h76g2000cwa.googlegroups.com...
[quoted text, click to view]

Bmack500
6/9/2006 10:14:56 AM
Thanks! Worked great. I didn't think that it would search for it is a
string...

[quoted text, click to view]
AddThis Social Bookmark Button