Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting value from Binary field
Message
From
27/01/2014 13:36:12
 
 
To
27/01/2014 13:33:18
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01592445
Message ID:
01592456
Views:
72
This message has been marked as the solution to the initial question of the thread.
>>I think you have to convert the byte array (loDataParameterSQLClient.Value) to hex ?
>>
>>
>>declare @Tmp table
>>(	Id int IDENTITY(1,1) NOT NULL,
>>	MD5 binary(16) not null
>>);
>>
>>insert into @Tmp (MD5) values (0xB3C54EFB6C02017046905007293650B1);
>>insert into @Tmp (MD5) values (0xB3C54EFB6C02017046905007293650B2);
>>
>>declare @MD5 Binary(16);
>>SET @MD5 = 0xB3C54EFB6C02017046905007293650B2;
>>
>>
>>select * from @Tmp where (MD5 = @MD5);
>>
>
>If I put 0x + loDataParameterSQLClient.Value, it will end up with 0xSystem.Byte[].


That's because of the default ToString method
       internal  static void Go()
       {
          // TestAll();
           byte[] pp = new byte[] { 1, 2, 3 };
           string x = "0x" + ToHex(pp);

           Console.WriteLine(x);
       }
       static string ToHex(byte[] bytes)
       {
           int length = bytes.Length;
           StringBuilder sb = new StringBuilder(length << 1);
           for (int i = -1; ++i < length; )
           {
               sb.AppendFormat("{0:X2}", bytes[i]);
           }
           return sb.ToString();
       }
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform