views:

461

answers:

1

I was wondering if anyone knew how to compile a text query for sql compact that goes like this :

command.CommandText = "SELECT * FROM tableName WHERE id = binary_Data"

The id column is a 32 byte binary column that is indexed and "binary_Data" is the binary data to compare to, but I am not sure how to get a "binary_Data" into the text query so sql can compare it.

+3  A: 

The best way is to use parameters:

command.CommandText = "SELECT * FROM TableName WHERE id = @binary_data";
command.Parameters.AddWithValue("@binary_data", byteArray);

Alternatively, you could manually build a hex string prefixed with 0x to create a binary literal to append to the query but it's not recommended.

Mehrdad Afshari
Appreciate the answer :-)
NastyNateDoggy