OLE DB Parameters
OLE DB parameters are used to supply values to an OLE DB query. They allow you to provide data to be used in the query, such as values for variables or constants.
Key Concepts
- Parameter Class: The base class for all OLE DB parameters.
- ParameterCollection: A collection of parameters that can be added to a query.
- Name: The name of the parameter, which is used in the query.
- Value: The value of the parameter.
Example
Here's a simple example of how to use OLE DB parameters:
using System.Data.OleDb;
// ... (connection and other setup) ...
OleDbCommand cmd = new OleDbCommand("SELECT * FROM Customers WHERE City = @City", connection);
cmd.Parameters.AddWithValue("@City", "London");
In this example, the query "SELECT * FROM Customers WHERE City = @City" uses a parameter named "@City". The value "London" is then passed to the parameter using the `AddWithValue` method.
Properties
- Name: (String) The name of the parameter.
- Value: (Object) The value of the parameter. The data type of this property depends on the data type of the parameter.
- ValueType: (Type) The data type of the value.
See the Parameter Class for more details.