asp.net.ph

SqlParameter.SqlDbType Property

System.Data.SqlClient Namespace   SqlParameter Class


Sets or retrieves the SqlDbType of the parameter.

Syntax


Script SqlParameter.SqlDbType [ = enumValue ]

Property Value


enumValue One of the SqlDbType values.

The property is read/write with a default value of NVarChar.

Exceptions


Exception Type Condition
ArgumentOutOfRangeException The property was not set to a valid SqlDbType.

Remarks

Use the SqlDbType property to specify or determine the SQL Server™ data type ( SqlDbType ) of a given parameter.

The data type of a SqlParameter determines the type and range of values that are accepted for the parameter. For example, if you define a parameter with a tinyint data type, only numeric values ranging from 0 to 255 are accepted. An error is returned if a stored procedure is executed with a value incompatible with the data type.

SqlDbType and DbType are linked. Setting the SqlDbType changes the DbType to a supported SqlDbType enum value.

Example

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

public void CreateSqlParameter ( ) {
   SqlParameter myParam = new SqlParameter ( "@Description", SqlDbType.VarChar, 100 );
   myParam.Direction = ParameterDirection.Output;
}
  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