Name
SqlDbType [SQL Server only]
Synopsis
SqlDbTypedataType= Parameter.SqlDbType; Parameter.SqlDbType =dataType;
Specifies the SQL Server data type of the parameter, using the
SqlDbType enumeration in the
System.Data namespace. If this property is set,
the value of the Parameter is converted to this
type before it’s passed to the data source. The
default is a SqlDbType.NVarChar, a variable-length
string of Unicode characters.
Example
The following code snippet sets the
Parameter.SqlDbType property and then examines the
linked DbType. In this case, the linked
DbType value is DbType.Int32.
param.SqlDbType = SqlDbType.Int; Console.WriteLine(param.DbType.ToString());
Notes
Every SqlParameter class includes a
DbType property and a provider-specific
SqlDbType property. These two properties are
linked. When you set the SqlDbType property, the
DbType uses a compatible type and vice versa.
For more information about valid SQL Server data types, and their mappings to .NET framework types, see Appendix A.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access