如何将 sql 服务器字段大小转换为 vb.net (我的需要是针对 sql 服务器字段指定参数大小)

How to convert sql server field size to vb.net (My need is to specify parameter size against sql server field)

我想知道在 vb.net 和 sql 服务器字段中指定参数大小时是否存在任何大小差异。

Varchar(50) 在 sql 服务器和 SqlDbType.VarChar(???).

是否有任何从 sql 字段大小到 vb.net 的转换,或者它与 sql 服务器中的相同。

SqlParameter.Size Property

...

For variable-length data types, Size describes the maximum amount of data to transmit to the server. For example, for a Unicode string value, Size could be used to limit the amount of data sent to the server to the first one hundred characters.

If not explicitly set, the size is inferred from the actual size of the specified parameter value.

...

理想情况下,如果您知道参数大小或知道它们受到约束,则应该设置参数大小。