| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using System;
- using System.Data;
- using System.Data.Common;
- using System.Data.OleDb;
- namespace STMes.DataProvider
- {
- /// <summary>
- /// Implements access to the Data Provider for OLE DB.
- /// </summary>
- /// <remarks>
- /// See the <see cref="DbManager.AddDataProvider"/> method to find an example.
- /// </remarks>
- /// <seealso cref="DbManager.AddDataProvider">AddDataManager Method</seealso>
- public class OleDbDataProvider: IDataProvider
- {
- /// <summary>
- /// Creates the database connection object.
- /// </summary>
- /// <remarks>
- /// See the <see cref="DbManager.AddDataProvider"/> method to find an example.
- /// </remarks>
- /// <seealso cref="DbManager.AddDataProvider">AddDataManager Method</seealso>
- /// <returns>The database connection object.</returns>
- IDbConnection IDataProvider.CreateConnectionObject()
- {
- return new OleDbConnection();
- }
- IDbConnection IDataProvider.CreateConnectionObject(string connectionString )
- {
- OleDbConnection conn = new OleDbConnection(connectionString);
-
- return conn;
- }
- /// <summary>
- /// Creates the data adapter object.
- /// </summary>
- /// <remarks>
- /// See the <see cref="DbManager.AddDataProvider"/> method to find an example.
- /// </remarks>
- /// <seealso cref="DbManager.AddDataProvider">AddDataManager Method</seealso>
- /// <returns>A data adapter object.</returns>
- DbDataAdapter IDataProvider.CreateDataAdapterObject()
- {
- return new OleDbDataAdapter();
- }
- /// <summary>
- /// Populates the specified IDbCommand object's Parameters collection with
- /// parameter information for the stored procedure specified in the IDbCommand.
- /// </summary>
- /// <remarks>
- /// See the <see cref="DbManager.AddDataProvider"/> method to find an example.
- /// </remarks>
- /// <seealso cref="DbManager.AddDataProvider">AddDataManager Method</seealso>
- /// <param name="command">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.</param>
- void IDataProvider.DeriveParameters(IDbCommand command)
- {
- OleDbCommandBuilder.DeriveParameters((OleDbCommand)command);
- }
- /// <summary>
- /// Returns connection type.
- /// </summary>
- /// <remarks>
- /// See the <see cref="DbManager.AddDataProvider"/> method to find an example.
- /// </remarks>
- /// <seealso cref="DbManager.AddDataProvider">AddDataManager Method</seealso>
- /// <value>An instance of the <see cref="Type"/> class.</value>
- public Type ConnectionType
- {
- get
- {
- return typeof(OleDbConnection);
- }
- }
- /// <summary>
- /// Returns the data provider name.
- /// </summary>
- /// <remarks>
- /// See the <see cref="DbManager.AddDataProvider"/> method to find an example.
- /// </remarks>
- /// <seealso cref="DbManager.AddDataProvider">AddDataProvider Method</seealso>
- /// <value>Data provider name.</value>
- public string Name
- {
- get
- {
- return "OleDb";
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public IDbDataParameter CreateDataParameter()
- {
- // TODO: Ìí¼Ó OleDbDataProvider.CreateDataParameter ʵÏÖ
- return new OleDbParameter();
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="da"></param>
- /// <returns></returns>
- public Object CreateCommandBuilder(DbDataAdapter da)
- {
- return new OleDbCommandBuilder(da as OleDbDataAdapter ) as object;
- }
-
- /// <summary>
- /// Test Connection Info(OLE DB)
- /// </summary>
- /// <param name="db">Test Connection Object</param>
- /// <returns>Test Result</returns>
- public bool Ping(ref IDbConnection db)
- {
- // TODO: Ìí¼Ó OleDbDataProvider.Ping ʵÏÖ
- return true;
- }
- public int GetSID(ref IDbConnection db)
- {
- return -1;
- }
- }
- }
|