asp.net.ph

SqlParameter.Size Property

System.Data.SqlClient Namespace   SqlParameter Class


Sets or retrieves the maximum size of the parameter data.

Syntax


Script SqlParameter.Size [ = bytes ]

Property Value


bytes The maximum size, in bytes, of the data within the column.

The property is read/write with a default value inferred from the the parameter Value.

The maximum parameter size of the data.

Implements

IDbDataParameter.Size

Remarks

The Size property is used for binary and string types.

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

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

If not explicitly set, the size is inferred from the actual size of the specified parameter value. For fixed width data types, the value of Size is ignored It can be retrieved for informational purposes, and returns the maximum amount of bytes the provider utilizes when transmitting the value of the parameter to the server.

Example

The following example initializes an SqlParameter and sets some of its properties.

public void CreateSqlParameter ( ) {
   string myValue = "12 foot scarf - multiple colors, one previous owner";
   SqlParameter myParam = new SqlParameter ( "@Description", SqlDbType.VarChar );
   myParam.Direction = ParameterDirection.Output;
   myParam.Value = myValue;
   myParam.Size = myValue.Length;
}
  C# VB

See Also

SqlParameter Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph