Export (0) Print
Expand All

SqlParameter Constructor

.NET Framework 1.1

Initializes a new instance of the SqlParameter class.

Overload List

Initializes a new instance of the SqlParameter class.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New()
[C#] public SqlParameter();
[C++] public: SqlParameter();
[JScript] public function SqlParameter();

Initializes a new instance of the SqlParameter class with the parameter name and a value of the new SqlParameter.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(String, Object)
[C#] public SqlParameter(string, object);
[C++] public: SqlParameter(String*, Object*);
[JScript] public function SqlParameter(String, Object);

Initializes a new instance of the SqlParameter class with the parameter name and the data type.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(String, SqlDbType)
[C#] public SqlParameter(string, SqlDbType);
[C++] public: SqlParameter(String*, SqlDbType);
[JScript] public function SqlParameter(String, SqlDbType);

Initializes a new instance of the SqlParameter class with the parameter name, the SqlDbType, and the size.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(String, SqlDbType, Integer)
[C#] public SqlParameter(string, SqlDbType, int);
[C++] public: SqlParameter(String*, SqlDbType, int);
[JScript] public function SqlParameter(String, SqlDbType, int);

Initializes a new instance of the SqlParameter class with the parameter name, the SqlDbType, the size, and the source column name.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(String, SqlDbType, Integer, String)
[C#] public SqlParameter(string, SqlDbType, int, string);
[C++] public: SqlParameter(String*, SqlDbType, int, String*);
[JScript] public function SqlParameter(String, SqlDbType, int, String);

Initializes a new instance of the SqlParameter class with the parameter name, the type of the parameter, the size of the parameter, a ParameterDirection, the precision of the parameter, the scale of the parameter, the source column, a DataRowVersion to use, and the value of the parameter.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(String, SqlDbType, Integer, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object)
[C#] public SqlParameter(string, SqlDbType, int, ParameterDirection, bool, byte, byte, string, DataRowVersion, object);
[C++] public: SqlParameter(String*, SqlDbType, int, ParameterDirection, bool, unsigned char, unsigned char, String*, DataRowVersion, Object*);
[JScript] public function SqlParameter(String, SqlDbType, int, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object);

Example

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

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of the SqlParameter constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub CreateSqlParameter()
    Dim myParameter As New SqlParameter("@Description", SqlDbType.VarChar, 11, ParameterDirection.Input, True, 0, 0, "Description", DataRowVersion.Current, "garden hose")
    myParameter.IsNullable = True
End Sub 'CreateSqlParameter

[C#] 
public void CreateSqlParameter() 
 {
    SqlParameter myParameter = new SqlParameter("@Description",SqlDbType.VarChar,11,ParameterDirection.Input,
                 true,0,0,"Description",DataRowVersion.Current,"garden hose");
    myParameter.IsNullable = true;
 }

[C++] 
public:
void CreateSqlParameter() 
 {
    SqlParameter* myParameter = new SqlParameter(S"@Description",SqlDbType::VarChar,11,ParameterDirection::Input,
                 true,0,0,S"Description",DataRowVersion::Current,S"garden hose");
    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.

See Also

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

Show:
© 2014 Microsoft