Login  |  Register
 
August 19, 2008  
Changes needed to EDAB to implement the Access provider  
Location: BlogsADefWebserver's Blog    
Posted by: admin 6/22/2005 6:40 AM

I had hoped that I could simply make an Access provider without changing any of the base code in the EDAB. However I had to make these changes:

  

  1. Made these changes in the Data project described here http://www.geekswithblogs.net/cbreisch/archive/2005/05/03/38945.aspx
    1. In the file sr.cs file in the Data project, change:
    "internal class SR"
    to "public class SR"
    2. In the file ConnectionString.cs private string connectionStringWithoutCredentials needs to be public string connectionStringWithoutCredentials
    3. In the file DBCommandWrapper.cs file in the Data project, change:
    "internal void DiscoverParameters(char parameterToken)"
    to "public void DiscoverParameters(char parameterToken)"
  2. Changed        private IDataReader DoExecuteReader(IDbCommand command, CommandBehavior cmdBehavior) in “database.cs” to
    public IDataReader DoExecuteReader(IDbCommand command, CommandBehavior cmdBehavior)
    (to allow it to be accessed from "
    public override IDataReader ExecuteReader(DBCommandWrapper command)" in oleDbDatabase.cs)
  3. Changed        private void DoExecuteNonQuery(DBCommandWrapper command) in “database.cs” to
    public void DoExecuteNonQuery(DBCommandWrapper command)
    (to allow it to be accessed from "
    public override void ExecuteNonQuery(DBCommandWrapper command)" in oleDbDatabase.cs)
  4. To get rid of the “Failed to create instances of performance counter” error (from http://blogs.msdn.com/tomholl/archive/2005/02/18/376187.aspx?Pending=true “), in the Project Properties dialog for the Common project, and under Configuration Properties\Build, find the Conditional Compilation Properties property and remove ;USEWMI;USEEVENTLOG;USEPERFORMANCECOUNTER”
  5. Kevin Weir made these changes to "SQLCommandWrapper.cs":

  protected override void DoAssignParameterValues()
  {
   if (SameNumberOfParametersAndValues() == false)
   {
    throw new InvalidOperationException(SR.ExceptionMessageParameterMatchFailure);
   }

   int inputParameterCount = 0;
   for (int i = 0; i < this.command.Parameters.Count; i++)
   {
    IDataParameter parameter = this.command.Parameters[i];

    // There used to be code here that checked to see if the parameter was input or input/output
    // before assigning the value to it. We took it out because of an operational bug with
    // deriving parameters for a stored procedure. It turns out that output parameters are set
    // to input/output after discovery, so any direction checking was unneeded. Should it ever
    // be needed, it should go here, and check that a parameter is input or input/output before
    // assigning a value to it.
    if (parameter.Direction == ParameterDirection.InputOutput | parameter.Direction == ParameterDirection.ReturnValue)
    {
     SetParameterValue(parameter.ParameterName, null);
    }
    else
    {
     SetParameterValue(parameter.ParameterName, this.parameterValues[inputParameterCount]);
     inputParameterCount++;
    }
   }
  }

 

        private bool SameNumberOfParametersAndValues()
        {
   int numberOfOutputParameters = 0;
   for (int i = 0; i < this.command.Parameters.Count; i++)
   {
    IDataParameter parameter = this.command.Parameters[i];

    if (parameter.Direction == ParameterDirection.InputOutput | parameter.Direction == ParameterDirection.ReturnValue)
    {
     numberOfOutputParameters++;
    }
   }
   return this.command.Parameters.Count - numberOfOutputParameters == this.parameterValues.Length;
        }

Blog Archive  
Blog List  
Search NewBlog