Export (0) Print
Expand All

OdbcParameter Class

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Represents a parameter to an OdbcCommand and optionally, its mapping to a DataColumn. This class cannot be inherited.

For a list of all members of this type, see OdbcParameter Members.

System.Object
   System.MarshalByRefObject
      System.Data.Odbc.OdbcParameter

[Visual Basic]
NotInheritable Public Class OdbcParameter
   Inherits MarshalByRefObject
   Implements IDbDataParameter, IDataParameter, ICloneable
[C#]
public sealed class OdbcParameter : MarshalByRefObject,
   IDbDataParameter, IDataParameter, ICloneable
[C++]
public __gc __sealed class OdbcParameter : public
   MarshalByRefObject, IDbDataParameter, IDataParameter, ICloneable
[JScript]
public class OdbcParameter extends MarshalByRefObject implements
   IDbDataParameter, IDataParameter, ICloneable

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

Parameter names are not case-sensitive.

Example

[Visual Basic, C#, C++] The following example creates multiple instances of OdbcParameter through the OdbcParameterCollection within the OdbcDataAdapter. These parameters are used to select data from the data source and place the data in the DataSet. This example assumes that a DataSet and an OdbcDataAdapter have already been created with the appropriate schema, commands, and connection.

[Visual Basic] 
Public Sub AddOdbcParameters()
    ' ...
    ' create myDataSet and myDataAdapter
    ' ...
myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", OdbcType.VarChar, 80).Value = "toasters"
myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", OdbcType.Int).Value = 239
myDataAdapter.Fill(myDataSet)
End Sub 'AddOdbcParameters

[C#] 
public void AddOdbcParameters() 
 {
 // ...
 // create myDataSet and myDataAdapter
 // ...
   myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", OdbcType.VarChar, 80).Value = "toasters";
   myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", OdbcType.Int).Value = 239;
   myDataAdapter.Fill(myDataSet);
 }

[C++] 
public:
    void AddOdbcParameters()
    {
        // ...
        // create myDataSet and myDataAdapter
        // ...
        myDataAdapter->SelectCommand->Parameters->Add(S"@CategoryName", OdbcType::VarChar, 80)->Value = S"toasters";
        myDataAdapter->SelectCommand->Parameters->Add(S"@SerialNum", OdbcType::Int)->Value = __box(239);
        myDataAdapter->Fill(myDataSet);
    }

[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.

Requirements

Namespace: System.Data.Odbc

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

Assembly: System.Data (in System.Data.dll)

See Also

OdbcParameter Members | System.Data.Odbc Namespace

Show:
© 2014 Microsoft