Пример #1
0
        private void CreateAccessor()
        {
            Debug.Assert(System.Data.CommandType.Text == CommandType || System.Data.CommandType.StoredProcedure == CommandType, "CreateAccessor: incorrect CommandType");
            Debug.Assert(null == _dbBindings, "CreateAccessor: already has dbBindings");
            Debug.Assert(HasParameters(), "CreateAccessor: unexpected, no parameter collection");

            // do this first in-case the command doesn't support parameters
            UnsafeNativeMethods.ICommandWithParameters commandWithParameters = ICommandWithParameters();

            OleDbParameterCollection collection = _parameters !;

            OleDbParameter[] parameters = new OleDbParameter[collection.Count];
            collection.CopyTo(parameters, 0);

            // _dbBindings is used as a switch during ExecuteCommand, so don't set it until everything okay
            Bindings bindings = new Bindings(parameters, collection.ChangeID);

            for (int i = 0; i < parameters.Length; ++i)
            {
                bindings.ForceRebind |= parameters[i].BindParameter(i, bindings);
            }

            bindings.AllocateForAccessor(null, 0, 0);

            ApplyParameterBindings(commandWithParameters, bindings.BindInfo !);

            UnsafeNativeMethods.IAccessor iaccessor = IAccessor();
            OleDbHResult hr = bindings.CreateAccessor(iaccessor, ODB.DBACCESSOR_PARAMETERDATA);

            if (hr < 0)
            {
                ProcessResults(hr);
            }
            _dbBindings = bindings;
        }
        private void CreateAccessor()
        {
            System.Data.Common.UnsafeNativeMethods.ICommandWithParameters commandWithParameters = this.ICommandWithParameters();
            OleDbParameterCollection parameters = this._parameters;

            OleDbParameter[] array = new OleDbParameter[parameters.Count];
            parameters.CopyTo(array, 0);
            Bindings bindings = new Bindings(array, parameters.ChangeID);

            for (int i = 0; i < array.Length; i++)
            {
                bindings.ForceRebind |= array[i].BindParameter(i, bindings);
            }
            bindings.AllocateForAccessor(null, 0, 0);
            this.ApplyParameterBindings(commandWithParameters, bindings.BindInfo);
            System.Data.Common.UnsafeNativeMethods.IAccessor iaccessor = this.IAccessor();
            OleDbHResult hr = bindings.CreateAccessor(iaccessor, 4);

            if (hr < OleDbHResult.S_OK)
            {
                this.ProcessResults(hr);
            }
            this._dbBindings = bindings;
        }
Пример #3
0
        private void CreateAccessor() {
            Debug.Assert(System.Data.CommandType.Text == CommandType || System.Data.CommandType.StoredProcedure == CommandType, "CreateAccessor: incorrect CommandType");
            Debug.Assert(null == _dbBindings, "CreateAccessor: already has dbBindings");
            Debug.Assert(HasParameters(), "CreateAccessor: unexpected, no parameter collection");

            // do this first in-case the command doesn't support parameters
            UnsafeNativeMethods.ICommandWithParameters commandWithParameters = ICommandWithParameters();

            OleDbParameterCollection collection = _parameters;
            OleDbParameter[] parameters = new OleDbParameter[collection.Count];
            collection.CopyTo(parameters, 0);

            // _dbBindings is used as a switch during ExecuteCommand, so don't set it until everything okay
            Bindings bindings = new Bindings(parameters, collection.ChangeID);

            for (int i = 0; i < parameters.Length; ++i) {
                bindings.ForceRebind |= parameters[i].BindParameter(i, bindings);
            }

            bindings.AllocateForAccessor(null, 0, 0);

            ApplyParameterBindings(commandWithParameters, bindings.BindInfo);

            UnsafeNativeMethods.IAccessor iaccessor = IAccessor();
            OleDbHResult hr = bindings.CreateAccessor(iaccessor, ODB.DBACCESSOR_PARAMETERDATA);
            if (hr < 0) {
                ProcessResults(hr);
            }
            _dbBindings = bindings;
        }
 private void CreateAccessor()
 {
     System.Data.Common.UnsafeNativeMethods.ICommandWithParameters commandWithParameters = this.ICommandWithParameters();
     OleDbParameterCollection parameters = this._parameters;
     OleDbParameter[] array = new OleDbParameter[parameters.Count];
     parameters.CopyTo(array, 0);
     Bindings bindings = new Bindings(array, parameters.ChangeID);
     for (int i = 0; i < array.Length; i++)
     {
         bindings.ForceRebind |= array[i].BindParameter(i, bindings);
     }
     bindings.AllocateForAccessor(null, 0, 0);
     this.ApplyParameterBindings(commandWithParameters, bindings.BindInfo);
     System.Data.Common.UnsafeNativeMethods.IAccessor iaccessor = this.IAccessor();
     OleDbHResult hr = bindings.CreateAccessor(iaccessor, 4);
     if (hr < OleDbHResult.S_OK)
     {
         this.ProcessResults(hr);
     }
     this._dbBindings = bindings;
 }