using System;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
namespace STMes.DataProvider
{
///
/// Implements access to the Data Provider for OLE DB.
///
///
/// See the method to find an example.
///
/// AddDataManager Method
public class OleDbDataProvider: IDataProvider
{
///
/// Creates the database connection object.
///
///
/// See the method to find an example.
///
/// AddDataManager Method
/// The database connection object.
IDbConnection IDataProvider.CreateConnectionObject()
{
return new OleDbConnection();
}
IDbConnection IDataProvider.CreateConnectionObject(string connectionString )
{
OleDbConnection conn = new OleDbConnection(connectionString);
return conn;
}
///
/// Creates the data adapter object.
///
///
/// See the method to find an example.
///
/// AddDataManager Method
/// A data adapter object.
DbDataAdapter IDataProvider.CreateDataAdapterObject()
{
return new OleDbDataAdapter();
}
///
/// Populates the specified IDbCommand object's Parameters collection with
/// parameter information for the stored procedure specified in the IDbCommand.
///
///
/// See the method to find an example.
///
/// AddDataManager Method
/// The IDbCommand referencing the stored procedure for which the parameter information is to be derived. The derived parameters will be populated into the Parameters of this command.
void IDataProvider.DeriveParameters(IDbCommand command)
{
OleDbCommandBuilder.DeriveParameters((OleDbCommand)command);
}
///
/// Returns connection type.
///
///
/// See the method to find an example.
///
/// AddDataManager Method
/// An instance of the class.
public Type ConnectionType
{
get
{
return typeof(OleDbConnection);
}
}
///
/// Returns the data provider name.
///
///
/// See the method to find an example.
///
/// AddDataProvider Method
/// Data provider name.
public string Name
{
get
{
return "OleDb";
}
}
///
///
///
///
public IDbDataParameter CreateDataParameter()
{
// TODO: 添加 OleDbDataProvider.CreateDataParameter 实现
return new OleDbParameter();
}
///
///
///
///
///
public Object CreateCommandBuilder(DbDataAdapter da)
{
return new OleDbCommandBuilder(da as OleDbDataAdapter ) as object;
}
///
/// Test Connection Info(OLE DB)
///
/// Test Connection Object
/// Test Result
public bool Ping(ref IDbConnection db)
{
// TODO: 添加 OleDbDataProvider.Ping 实现
return true;
}
public int GetSID(ref IDbConnection db)
{
return -1;
}
}
}