This documentation is archived and is not being maintained.

SqlParameter.SqlDbType Property

Gets or sets the SqlDbType of the parameter.

[Visual Basic]
Public Property SqlDbType As SqlDbType
public SqlDbType SqlDbType {get; set;}
public: __property SqlDbType get_SqlDbType();
public: __property void set_SqlDbType(SqlDbType);
public function get SqlDbType() : SqlDbType;
public function set SqlDbType(SqlDbType);

Property Value

One of the SqlDbType values. The default is NVarChar.


The SqlDbType and DbType are linked. Therefore, setting the DbType changes the SqlDbType to a supporting SqlDbType.

For a list of the supported data types, see the appropriate SqlDbType member. For more information, see Using Parameters with a DataAdapter.


[Visual Basic, C#, C++] The following example creates a SqlParameter and sets some of its properties.

[Visual Basic] 
Public Sub CreateSqlParameter()
    Dim myParameter As New SqlParameter("@Description", SqlDbType.VarChar)
    myParameter.IsNullable = True
End Sub 'CreateSqlParameter

public void CreateSqlParameter() 
    SqlParameter myParameter = new SqlParameter("@Description", SqlDbType.VarChar);
    myParameter.IsNullable = true;

void CreateSqlParameter() 
    SqlParameter* myParameter = new SqlParameter(S"@Description", SqlDbType::VarChar);
    myParameter->IsNullable = true;

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

SqlParameter Class | SqlParameter Members | System.Data.SqlClient Namespace | DbType