Question

I have a problem I cannot figure out. In my C# (VS) project I get results from my DB but not when using a WHERE-clause specifying a GUID value.

The SQLCommand below never returns any results, the query works on same computer for sqlcmd and it works on the DB server

SqlCommand blobSQL = new SqlCommand("SELECT [DocumentData] FROM [archive].[dbo].[tbl] WHERE [Part.PartID] = '31A799AA-508D-4757-9DB5-167C2B75B197'", dataConnection);

This query returns results

SqlCommand blobSQL = new SqlCommand("SELECT [DocumentData] FROM [archive].[dbo].[tbl]", dataConnection);

I can't figure out what is wrong.

EDIT: To clear things up a bit this is the table:

Part.PartID                             DocumentData
31A799AA-508D-4757-9DB5-167C2B75B197    0x255044462...
717FE1D1-EEBF-46B5-8445-1A7CE0247C0F    0x255044462...
C04CCBB0-E2DC-4B94-911C-57571F6A04A6    0x255044462...
7F27C60C-3C29-42EE-9575-8E8B0E76BCE6    0x255044462...
Was it helpful?

Solution

There is a GUID class in C#. If you store id in GUID object, and add it to your query using parameters, it might work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top