Ejemplo n.º 1
0
        //protected override int Fill(DataTable dataTable, IDataReader dataReader) {
        //    return base.Fill(dataTable, dataReader);
        //}

        private int FillFromRecordset(object data, UnsafeNativeMethods.ADORecordsetConstruction recordset, string?srcTable, out bool incrementResultCount)
        {
            incrementResultCount = false;

            IntPtr chapter; /*ODB.DB_NULL_HCHAPTER*/
            object?result;

            try
            {
                result  = recordset.get_Rowset();
                chapter = recordset.get_Chapter();
            }
            catch (Exception e)
            {
                // UNDONE - should not be catching all exceptions!!!
                if (!ADP.IsCatchableExceptionType(e))
                {
                    throw;
                }

                throw ODB.Fill_EmptyRecordSet("ADODBRecordSet", e);
            }

            if (null != result)
            {
                CommandBehavior behavior = (MissingSchemaAction.AddWithKey != MissingSchemaAction) ? 0 : CommandBehavior.KeyInfo;
                behavior |= CommandBehavior.SequentialAccess;

                OleDbDataReader?dataReader = null;
                try
                {
                    // initialized with chapter only since we don't want ReleaseChapter called for this chapter handle
                    ChapterHandle chapterHandle = ChapterHandle.CreateChapterHandle(chapter);

                    dataReader = new OleDbDataReader(null, null, 0, behavior);
                    dataReader.InitializeIRowset(result, chapterHandle, ADP.RecordsUnaffected);
                    dataReader.BuildMetaInfo();

                    incrementResultCount = (0 < dataReader.FieldCount);
                    if (incrementResultCount)
                    {
                        if (data is DataTable)
                        {
                            return(base.Fill((DataTable)data, dataReader));
                        }
                        else
                        {
                            return(base.Fill((DataSet)data, srcTable !, dataReader, 0, 0));
                        }
                    }
                }
                finally
                {
                    dataReader?.Close();
                }
            }
            return(0);
        }
        private int FillFromRecordset(object data, System.Data.Common.UnsafeNativeMethods.ADORecordsetConstruction recordset, string srcTable, out bool incrementResultCount)
        {
            IntPtr ptr;

            incrementResultCount = false;
            object result = null;

            try
            {
                Bid.Trace("<oledb.ADORecordsetConstruction.get_Rowset|API|ADODB>\n");
                result = recordset.get_Rowset();
                Bid.Trace("<oledb.ADORecordsetConstruction.get_Rowset|API|ADODB|RET> %08X{HRESULT}\n", 0);
                Bid.Trace("<oledb.ADORecordsetConstruction.get_Chapter|API|ADODB>\n");
                ptr = recordset.get_Chapter();
                Bid.Trace("<oledb.ADORecordsetConstruction.get_Chapter|API|ADODB|RET> %08X{HRESULT}\n", 0);
            }
            catch (Exception exception)
            {
                if (!ADP.IsCatchableExceptionType(exception))
                {
                    throw;
                }
                throw ODB.Fill_EmptyRecordSet("ADODBRecordSet", exception);
            }
            if (result != null)
            {
                CommandBehavior commandBehavior = (MissingSchemaAction.AddWithKey != base.MissingSchemaAction) ? CommandBehavior.Default : CommandBehavior.KeyInfo;
                commandBehavior |= CommandBehavior.SequentialAccess;
                OleDbDataReader dataReader = null;
                try
                {
                    ChapterHandle chapterHandle = ChapterHandle.CreateChapterHandle(ptr);
                    dataReader = new OleDbDataReader(null, null, 0, commandBehavior);
                    dataReader.InitializeIRowset(result, chapterHandle, ADP.RecordsUnaffected);
                    dataReader.BuildMetaInfo();
                    incrementResultCount = 0 < dataReader.FieldCount;
                    if (incrementResultCount)
                    {
                        if (data is DataTable)
                        {
                            return(base.Fill((DataTable)data, dataReader));
                        }
                        return(base.Fill((DataSet)data, srcTable, dataReader, 0, 0));
                    }
                }
                finally
                {
                    if (dataReader != null)
                    {
                        dataReader.Close();
                    }
                }
            }
            return(0);
        }
Ejemplo n.º 3
0
        private void DisposeNativeRowset() {
            UnsafeNativeMethods.IRowset irowset = _irowset;
            _irowset = null;

            ChapterHandle chapter = _chapterHandle;
            _chapterHandle = ChapterHandle.DB_NULL_HCHAPTER;

            if (ChapterHandle.DB_NULL_HCHAPTER != chapter) { // MDAC 81441
                chapter.Dispose();
            }

            if (null != irowset) {
                Marshal.ReleaseComObject(irowset);
            }
        }
Ejemplo n.º 4
0
        internal void InitializeIRowset(object result, ChapterHandle chapterHandle, IntPtr recordsAffected) {
            // if from ADODB, connection will be null
            if ((null == _connection) || (ChapterHandle.DB_NULL_HCHAPTER != chapterHandle)) { // MDAC 59629
                _rowHandleFetchCount = new IntPtr(1);
            }

            Initialize();
            _recordsAffected = recordsAffected;
            _irowset = (UnsafeNativeMethods.IRowset) result; // maybe null if no results
            _chapterHandle = chapterHandle;
        }
Ejemplo n.º 5
0
        //override protected int Fill(DataTable dataTable, IDataReader dataReader) { // MDAC 65506
        //    return base.Fill(dataTable, dataReader);
        //}

        private int FillFromRecordset(Object data, UnsafeNativeMethods.ADORecordsetConstruction recordset, string srcTable, out bool incrementResultCount)
        {
            incrementResultCount = false;

            IntPtr chapter; /*ODB.DB_NULL_HCHAPTER*/
            object result = null;

            try {
                Bid.Trace("<oledb.ADORecordsetConstruction.get_Rowset|API|ADODB>\n");
                result = recordset.get_Rowset(); // MDAC 83342
                Bid.Trace("<oledb.ADORecordsetConstruction.get_Rowset|API|ADODB|RET> %08X{HRESULT}\n", 0);

                Bid.Trace("<oledb.ADORecordsetConstruction.get_Chapter|API|ADODB>\n");
                chapter = recordset.get_Chapter(); // MDAC 83342
                Bid.Trace("<oledb.ADORecordsetConstruction.get_Chapter|API|ADODB|RET> %08X{HRESULT}\n", 0);
            }
            catch (Exception e) {
                //
                if (!ADP.IsCatchableExceptionType(e))
                {
                    throw;
                }

                throw ODB.Fill_EmptyRecordSet("ADODBRecordSet", e);
            }

            if (null != result)
            {
                CommandBehavior behavior = (MissingSchemaAction.AddWithKey != MissingSchemaAction) ? 0 : CommandBehavior.KeyInfo;
                behavior |= CommandBehavior.SequentialAccess;

                OleDbDataReader dataReader = null;
                try {
                    // intialized with chapter only since we don't want ReleaseChapter called for this chapter handle
                    ChapterHandle chapterHandle = ChapterHandle.CreateChapterHandle(chapter);

                    dataReader = new OleDbDataReader(null, null, 0, behavior);
                    dataReader.InitializeIRowset(result, chapterHandle, ADP.RecordsUnaffected);
                    dataReader.BuildMetaInfo();

                    incrementResultCount = (0 < dataReader.FieldCount); // MDAC 59632
                    if (incrementResultCount)
                    {
                        if (data is DataTable)
                        {
                            return(base.Fill((DataTable)data, dataReader)); // MDAC 65506
                        }
                        else
                        {
                            return(base.Fill((DataSet)data, srcTable, dataReader, 0, 0));
                        }
                    }
                }
                finally {
                    if (null != dataReader)
                    {
                        dataReader.Close();
                    }
                }
            }
            return(0);
        }
 private void DisposeNativeRowset()
 {
     System.Data.Common.UnsafeNativeMethods.IRowset o = this._irowset;
     this._irowset = null;
     ChapterHandle handle = this._chapterHandle;
     this._chapterHandle = ChapterHandle.DB_NULL_HCHAPTER;
     if (ChapterHandle.DB_NULL_HCHAPTER != handle)
     {
         handle.Dispose();
     }
     if (o != null)
     {
         Marshal.ReleaseComObject(o);
     }
 }
 internal void InitializeIRowset(object result, ChapterHandle chapterHandle, IntPtr recordsAffected)
 {
     if ((this._connection == null) || (ChapterHandle.DB_NULL_HCHAPTER != chapterHandle))
     {
         this._rowHandleFetchCount = new IntPtr(1);
     }
     this.Initialize();
     this._recordsAffected = recordsAffected;
     this._irowset = (System.Data.Common.UnsafeNativeMethods.IRowset) result;
     this._chapterHandle = chapterHandle;
 }