Export (0) Print
Expand All

DbParameter.Size Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the maximum size, in bytes, of the data within the column.

Namespace: System.Data.Common
Assembly: System.Data (in system.data.dll)

public abstract int Size { get; set; 
/** @property */
public abstract int get_Size ()

/** @property */
public abstract void set_Size (int value)

public abstract function get Size () : int

public abstract function set Size (value : int)

Property Value

The maximum size, in bytes, of the data within the column. The default value is inferred from the parameter value.

The Size property is used for binary and string types.

For nonstring data types and ANSI string data, the Size property refers to the number of bytes. For Unicode string data, Size refers to the number of characters. The count for strings does not include the terminating character.

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.

For bidirectional and output parameters, and return values, you must set the value of Size. This is not required for input parameters, and if not explicitly set, the value of is inferred from the actual size of the specified parameter when a parameterized statement is executed.

The DbType and Size properties of a parameter can be inferred by setting Value. Therefore, you are not required to specify them. However, they are not exposed in DbParameter property settings. For example, if the size of the parameter has been inferred, Size does not contain inferred value after statement execution.

For fixed length data types, the value of Size is ignored. It can be retrieved for informational purposes, and returns the maximum amount of bytes the provider uses when transmitting the value of the parameter to the server.

If the size of the value supplied for a DbParameter exceeds the specified Size, the Value of the DbParameter will contain the specified value, truncated to the Size of the DbParameter.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft