Reputation: 853
I need to run a stored procedure from code. One of the input parameters is rowVersion of the table. rowVersion is a byte array ( {0, 0, 0, 0, 0, 0, 13, 191} that's 0x0000000000000DBF in db). So if to add rowVersion this way :
cmd.Parameters.AddWithValue("@myPKRowversion", 0x0000000000000DBF);
my sp is working. But when I'm adding it like here:
uint a = 0x0000000000000DBF;
cmd.Parameters.AddWithValue("@myPKRowversion", a);
or if I convert byte Array to string like:
string a = "0x0000000000000DBF";
cmd.Parameters.AddWithValue("@myPKRowversion", a);
my sp is not working. What should I do to make my sp work?
Upvotes: 0
Views: 336
Reputation: 1500495
I suggest you add it as a byte array. For example:
byte[] bytes = new byte[] { 0, 0, 0, 0, 0, 0, 13, 191 };
cmd.Parameters.Add("@myPKRowVersion", SqlDbType.Binary).Value = bytes;
If you're trying to specify bytes, the most natural type is a byte array...
Upvotes: 3