在sql server中保存字节数组

2021-11-18 00:00:00 bytearray sql-server sqlcommand

我希望使用一种方法来保存需要使用字节数组的密码,如本 发布

Am looking to use an approach in saving passwords that requires using byte array as in this post

那么我应该在 sql server 中使用哪种数据类型来保存字节数组?以及如何使用 SqlCommand 传递和检索字节数组?

So which data type should i use in sql server to save byte array? and how can i pass and retrieve the byte array using SqlCommand?

推荐答案

如果它总是相同的长度,那么 binary(length) 将是合适的.如果它的长度会有所不同,请使用 varbinary(maxlength).

If it's always going to be the same length, then binary(length) would be suitable. If it's going to vary in length, use varbinary(maxlength).

二进制和 varbinary.

而且,正如@p.s.w.g 所说,您可以通过将其放入合适的参数中来从代码中传递它.

And, as @p.s.w.g says, you pass it from code by placing it into a suitable parameter.

相关文章