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.

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.