简体   繁体   English

如果 DbParameter.DbType 是 Binary,那么 DbParameter.Size 的值是多少?

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

I am working with Visual Studio 2010, .Net Framework 4 and SQL Server 2008 R2.我正在使用 Visual Studio 2010、.Net Framework 4 和 SQL Server 2008 R2。

I have a table and one of its column's data type is timestamp .我有一个表,其列的数据类型之一是timestamp I am trying to setup a DbParameter for this column.我正在尝试为此列设置一个DbParameter Looking at https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings I can see that the DbParameter.DbType for this column should be Binary .查看https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings我可以看到该列的DbParameter.DbType应该是Binary But what should be the value of DbParameter.Size for this column?但是该列的DbParameter.Size值应该是多少?

Thanks谢谢

Sorry to read you got stuck in the past.很抱歉读到你被困在过去。 I'll send Doc Brown to get you back to 2019. I mean, seriously, Don't you think it's high time to upgrade your VS and SQL Server?我会派布朗博士让你回到 2019 年。我的意思是,说真的,你不认为是时候升级你的 VS 和 SQL 服务器了吗?

To answer your question, In SQL Server, Timestamp is a synonym to RowVersion .要回答您的问题,在 SQL 服务器中, TimestampRowVersion同义词
From documentation:从文档:

[rowversion] Is a data type that exposes automatically generated, unique binary numbers within a database. [rowversion] 是一种数据类型,它在数据库中公开自动生成的唯一二进制数。 rowversion is generally used as a mechanism for version-stamping table rows. rowversion 通常用作对表行进行版本标记的机制。 The storage size is 8 bytes.存储大小为 8 个字节。 The rowversion data type is just an incrementing number and does not preserve a date or a time. rowversion 数据类型只是一个递增的数字,不保留日期或时间。

(emphasis mine) (强调我的)

Also, from the same documentation page:此外,从同一文档页面:

Note笔记

The timestamp syntax is deprecated.时间戳语法已弃用。 This feature is in maintenance mode and may be removed in a future version of Microsoft SQL Server.此功能处于维护模式,可能会在 Microsoft SQL 服务器的未来版本中删除。 Avoid using this feature in new development work, and plan to modify applications that currently use this feature.避免在新的开发工作中使用此功能,并计划修改当前使用此功能的应用程序。

BTW, RowVersion is automatically generated - so unless your parameter is an out parameter, I see no reason to use it in a parameter.顺便说一句, RowVersion是自动生成的——所以除非你的参数是一个out参数,否则我认为没有理由在参数中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM