Export (0) Print
Expand All
0 out of 3 rated this helpful - Rate this topic

OleDbParameter Class

Represents a parameter to an OleDbCommand and optionally, its mapping to a DataSet column. This class cannot be inherited.

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

System.Object
   System.MarshalByRefObject
      System.Data.OleDb.OleDbParameter

[Visual Basic]
NotInheritable Public Class OleDbParameter
   Inherits MarshalByRefObject
   Implements IDbDataParameter, IDataParameter, ICloneable
[C#]
public sealed class OleDbParameter : MarshalByRefObject,
   IDbDataParameter, IDataParameter, ICloneable
[C++]
public __gc __sealed class OleDbParameter : public
   MarshalByRefObject, IDbDataParameter, IDataParameter, ICloneable
[JScript]
public class OleDbParameter 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

The OLE DB .NET Provider uses positional parameters that are marked with a question mark (?) instead of named parameters.

Example

[Visual Basic, C#, C++] The following example creates multiple instances of OleDbParameter through the OleDbParameterCollection collection within the OleDbDataAdapter. 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 OleDbDataAdapter have already been created with the appropriate schema, commands, and connection.

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

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

[C++] 
public:
void AddOleDbParameters() 
 {
 // ...
 // create myDataSet and myDataAdapter
 // ...
   myDataAdapter->SelectCommand->Parameters->Add(S"@CategoryName", OleDbType::VarChar, 80)->Value = S"toasters";
   myDataAdapter->SelectCommand->Parameters->Add(S"@SerialNum", OleDbType::Integer)->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.OleDb

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

OleDbParameter Members | System.Data.OleDb Namespace

Show:
© 2014 Microsoft. All rights reserved.