如果 DbParameter.DbType 是二进制,DbParameter.Size 的值是多少?

What is the value of DbParameter.Size if DbParameter.DbType is Binary?

我正在使用 Visual Studio 2010、.Net Framework 4 和 SQL Server 2008 R2。

我有一个 table,其中一列的数据类型是 timestamp。我正在尝试为此专栏设置 DbParameter。查看 https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings 我可以看到此列的 DbParameter.DbType 应该是 Binary。但是该列的 DbParameter.Size 的值应该是多少?

谢谢

很抱歉得知您陷入了过去。我会派 Doc Brown 带你回到 2019 年。我的意思是,说真的,你不觉得是时候升级你的 VS 和 SQL 服务器了吗?

回答你的问题,在SQL服务器中,Timestamp是一个synonym to RowVersion
来自文档:

[rowversion] Is a data type that exposes automatically generated, unique binary numbers within a database. rowversion is generally used as a mechanism for version-stamping table rows. The storage size is 8 bytes. The rowversion data type is just an incrementing number and does not preserve a date or a time.

(强调我的)

此外,来自同一文档页面:

Note

The timestamp syntax is deprecated. This feature is in maintenance mode and may be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

顺便说一句,RowVersion 是自动生成的 - 因此除非您的参数是 out 参数,否则我认为没有理由在参数中使用它。