I have formed a hash key with the help of HashBytes as below with the multiple fields combination on SQL.
hashbytes('MD5', PID+PNumber+CONVERT(VARCHAR(50),cast(datestamp as binary)) +CONVERT(VARCHAR(50), TCount)+OCD+OSeqNbr+TID) AS VARBINARY(80)
All the above fileds datatypes are below
PID - nvarhcar(30)
PNumber - nvarhcar(30)
datestamp - Datetime
TCount - Int
OCD - varhcar(2)
OSeqNbr - varhcar(10)
TID - nvarhcar(100)
But i need C# equivalent function to get the value , so that i can get the value using c# code on the field values and then passes value to sql then compare the value against to the hash key column.
I have tried as below to get the byte[] value which is equivalent to the hash key binary value. But it is not the same value as sql hash key value.
var key = System.Text.Encoding.Unicode.GetBytes(Event.PID + Event.PNumber +
Event.DateStamp + Event.TCount +
Event.OCD + Event.OSeqNbr +
Event.TID);
Can anybody help on this what i am missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…