I have a database field whose dataType is varBinary. Now in a gridView I want to display that data. But i am getting output:
System.Byte[]
not the value
0x2C6D1A
which is in the database.
Please help how to solve this problem.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
BitConverterclass to format your byte array for display purposes:If you don’t want to convert directly to a
string, thenBitConverterhas a load of methods for converting from byte arrays to various other types.EDIT…
If you’re binding some query results directly to the
GridViewcontrol then it might be easier to convert yourVARBINARYcolumn to aVARCHARin the query itself:(Note: This type of conversion – from
VARBINARYtoVARCHARin'0x1234AB'format – only works correctly in SQL Server 2008. Earlier versions of SQL Server just cast the binary data directly to character data.)