OdbcParameterCollection.Add Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds an OdbcParameter to the OdbcParameterCollection.
Overloads
Add(OdbcParameter) |
Adds the specified OdbcParameter to the OdbcParameterCollection. |
Add(Object) |
Adds the specified OdbcParameter object to the OdbcParameterCollection. |
Add(String, OdbcType) |
Adds an OdbcParameter to the OdbcParameterCollection, given the parameter name and data type. |
Add(String, Object) |
Obsolete.
Obsolete.
Adds an OdbcParameter to the OdbcParameterCollection given the parameter name and value. |
Add(String, OdbcType, Int32) |
Adds an OdbcParameter to the OdbcParameterCollection, given the parameter name, data type, and column length. |
Add(String, OdbcType, Int32, String) |
Adds an OdbcParameter to the OdbcParameterCollection given the parameter name, data type, column length, and source column name. |
Add(OdbcParameter)
- Source:
- OdbcParameterCollection.cs
- Source:
- OdbcParameterCollection.cs
- Source:
- OdbcParameterCollection.cs
Adds the specified OdbcParameter to the OdbcParameterCollection.
public:
System::Data::Odbc::OdbcParameter ^ Add(System::Data::Odbc::OdbcParameter ^ value);
public System.Data.Odbc.OdbcParameter Add (System.Data.Odbc.OdbcParameter value);
override this.Add : System.Data.Odbc.OdbcParameter -> System.Data.Odbc.OdbcParameter
member this.Add : System.Data.Odbc.OdbcParameter -> System.Data.Odbc.OdbcParameter
Public Function Add (value As OdbcParameter) As OdbcParameter
Parameters
- value
- OdbcParameter
The OdbcParameter to add to the collection.
Returns
The index of the new OdbcParameter object.
Exceptions
The OdbcParameter specified in the value
parameter is already added to this or another OdbcParameterCollection.
The value
parameter is null.
See also
Applies to
Add(Object)
Adds the specified OdbcParameter object to the OdbcParameterCollection.
public:
override int Add(System::Object ^ value);
public:
virtual int Add(System::Object ^ value);
public override int Add (object value);
public int Add (object value);
override this.Add : obj -> int
abstract member Add : obj -> int
override this.Add : obj -> int
Public Overrides Function Add (value As Object) As Integer
Public Function Add (value As Object) As Integer
Parameters
Returns
The index of the new OdbcParameter object in the collection.
Implements
See also
Applies to
Add(String, OdbcType)
- Source:
- OdbcParameterCollection.cs
- Source:
- OdbcParameterCollection.cs
- Source:
- OdbcParameterCollection.cs
Adds an OdbcParameter to the OdbcParameterCollection, given the parameter name and data type.
public:
System::Data::Odbc::OdbcParameter ^ Add(System::String ^ parameterName, System::Data::Odbc::OdbcType odbcType);
public System.Data.Odbc.OdbcParameter Add (string? parameterName, System.Data.Odbc.OdbcType odbcType);
public System.Data.Odbc.OdbcParameter Add (string parameterName, System.Data.Odbc.OdbcType odbcType);
override this.Add : string * System.Data.Odbc.OdbcType -> System.Data.Odbc.OdbcParameter
member this.Add : string * System.Data.Odbc.OdbcType -> System.Data.Odbc.OdbcParameter
Public Function Add (parameterName As String, odbcType As OdbcType) As OdbcParameter
Parameters
- parameterName
- String
The name of the parameter.
Returns
The index of the new OdbcParameter object.
Examples
The following example adds an OdbcParameter to the Parameters collection.
public void CreateParamCollection()
{
OdbcCommand command = new OdbcCommand(
"SELECT * FROM Customers WHERE CustomerID = ?", connection);
OdbcParameterCollection paramCollection = command.Parameters;
object paramObject = new OdbcParameter(
"CustomerID", OdbcType.VarChar);
int paramIndex = paramCollection.Add(paramObject);
}
Public Sub CreateParamCollection(connection As OdbcConnection)
Dim command As New OdbcCommand( _
"SELECT * FROM Customers WHERE CustomerID = ?", connection)
Dim paramCollection As OdbcParameterCollection = command.Parameters
Dim paramObject As Object = New OdbcParameter( _
"CustomerID", OdbcType.VarChar)
Dim paramIndex As Integer = paramCollection.Add(paramObject)
End Sub
See also
Applies to
Add(String, Object)
- Source:
- OdbcParameterCollection.cs
- Source:
- OdbcParameterCollection.cs
- Source:
- OdbcParameterCollection.cs
Caution
Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value) instead.
Caution
Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value). http://go.microsoft.com/fwlink/?linkid=14202
Adds an OdbcParameter to the OdbcParameterCollection given the parameter name and value.
public:
System::Data::Odbc::OdbcParameter ^ Add(System::String ^ parameterName, System::Object ^ value);
[System.Obsolete("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value) instead.")]
public System.Data.Odbc.OdbcParameter Add (string? parameterName, object? value);
public System.Data.Odbc.OdbcParameter Add (string parameterName, object value);
[System.Obsolete("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value). http://go.microsoft.com/fwlink/?linkid=14202", false)]
public System.Data.Odbc.OdbcParameter Add (string parameterName, object value);
[<System.Obsolete("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value) instead.")>]
override this.Add : string * obj -> System.Data.Odbc.OdbcParameter
member this.Add : string * obj -> System.Data.Odbc.OdbcParameter
[<System.Obsolete("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value). http://go.microsoft.com/fwlink/?linkid=14202", false)>]
override this.Add : string * obj -> System.Data.Odbc.OdbcParameter
Public Function Add (parameterName As String, value As Object) As OdbcParameter
Parameters
- parameterName
- String
The name of the parameter.
- value
- Object
The Value of the OdbcParameter to add to the collection.
Returns
The index of the new OdbcParameter object.
- Attributes
Exceptions
The value
parameter is not an OdbcParameter.
Remarks
Use caution when using this overload of the Add method to specify integer parameter values. Because this overload takes a value
of type Object, you must convert the integer value to an Object type when the value is zero, as the following C# example demonstrates.
parameters.Add("@pname", Convert.ToInt32(0));
If you do not perform this conversion, the compiler will assume you are attempting to call the OdbcParameterCollection.Add overload.
See also
Applies to
Add(String, OdbcType, Int32)
- Source:
- OdbcParameterCollection.cs
- Source:
- OdbcParameterCollection.cs
- Source:
- OdbcParameterCollection.cs
Adds an OdbcParameter to the OdbcParameterCollection, given the parameter name, data type, and column length.
public:
System::Data::Odbc::OdbcParameter ^ Add(System::String ^ parameterName, System::Data::Odbc::OdbcType odbcType, int size);
public System.Data.Odbc.OdbcParameter Add (string? parameterName, System.Data.Odbc.OdbcType odbcType, int size);
public System.Data.Odbc.OdbcParameter Add (string parameterName, System.Data.Odbc.OdbcType odbcType, int size);
override this.Add : string * System.Data.Odbc.OdbcType * int -> System.Data.Odbc.OdbcParameter
member this.Add : string * System.Data.Odbc.OdbcType * int -> System.Data.Odbc.OdbcParameter
Public Function Add (parameterName As String, odbcType As OdbcType, size As Integer) As OdbcParameter
Parameters
- parameterName
- String
The name of the parameter.
- size
- Int32
The length of the column.
Returns
The index of the new OdbcParameter object.
Examples
The following example adds an OdbcParameter to the OdbcCommand.Parameters
collection.
public void CreateOdbcParamColl(OdbcConnection connection)
{
OdbcCommand command = new OdbcCommand(
"SELECT * FROM Customers WHERE CustomerID = ?", connection);
OdbcParameterCollection paramCollection = command.Parameters;
OdbcParameter parameter = paramCollection.Add(
"CustomerID", OdbcType.VarChar, 5);
}
Public Sub CreateOdbcParamColl(connection As OdbcConnection)
Dim command As New OdbcCommand( _
"SELECT * FROM Customers WHERE CustomerID = ?", connection)
Dim paramCollection As OdbcParameterCollection = _
command.Parameters
Dim parameter As OdbcParameter = _
paramCollection.Add("CustomerID", OdbcType.VarChar, 5)
End Sub
See also
Applies to
Add(String, OdbcType, Int32, String)
- Source:
- OdbcParameterCollection.cs
- Source:
- OdbcParameterCollection.cs
- Source:
- OdbcParameterCollection.cs
Adds an OdbcParameter to the OdbcParameterCollection given the parameter name, data type, column length, and source column name.
public:
System::Data::Odbc::OdbcParameter ^ Add(System::String ^ parameterName, System::Data::Odbc::OdbcType odbcType, int size, System::String ^ sourceColumn);
public System.Data.Odbc.OdbcParameter Add (string? parameterName, System.Data.Odbc.OdbcType odbcType, int size, string? sourceColumn);
public System.Data.Odbc.OdbcParameter Add (string parameterName, System.Data.Odbc.OdbcType odbcType, int size, string sourceColumn);
override this.Add : string * System.Data.Odbc.OdbcType * int * string -> System.Data.Odbc.OdbcParameter
member this.Add : string * System.Data.Odbc.OdbcType * int * string -> System.Data.Odbc.OdbcParameter
Public Function Add (parameterName As String, odbcType As OdbcType, size As Integer, sourceColumn As String) As OdbcParameter
Parameters
- parameterName
- String
The name of the parameter.
- size
- Int32
The length of the column.
- sourceColumn
- String
The name of the source column.
Returns
The index of the new OdbcParameter object.
Examples
The following example adds an OdbcParameter to the Parameters collection.
public void CreateParameterCollection(OdbcConnection connection)
{
OdbcCommand command = new OdbcCommand(
"SELECT * FROM Customers WHERE CustomerID = ?", connection);
OdbcParameterCollection paramCollection = command.Parameters;
OdbcParameter parameter = paramCollection.Add(
"CustomerID", OdbcType.VarChar, 5, "CustomerID");
}
Public Sub CreateParameterCollection(connection As OdbcConnection)
Dim command As New OdbcCommand( _
"SELECT * FROM Customers WHERE CustomerID = ?", connection)
Dim paramCollection As OdbcParameterCollection = command.Parameters
Dim parameter As OdbcParameter = paramCollection.Add( _
"CustomerID", OdbcType.VarChar, 5, "CustomerID")
End Sub
See also
Applies to
.NET