internal bool AddInfoKeywordsToTable(DataTable table, DataColumn keyword)
 {
     using (IDBInfoWrapper wrapper = this.IDBInfo())
     {
         string str;
         System.Data.Common.UnsafeNativeMethods.IDBInfo info = wrapper.Value;
         if (info == null)
         {
             return(false);
         }
         Bid.Trace("<oledb.IDBInfo.GetKeywords|API|OLEDB> %d#\n", base.ObjectID);
         OleDbHResult keywords = info.GetKeywords(out str);
         Bid.Trace("<oledb.IDBInfo.GetKeywords|API|OLEDB|RET> %08X{HRESULT}\n", keywords);
         if (keywords < OleDbHResult.S_OK)
         {
             this.ProcessResults(keywords);
         }
         if (str != null)
         {
             string[] strArray = str.Split(new char[] { ',' });
             for (int i = 0; i < strArray.Length; i++)
             {
                 DataRow row = table.NewRow();
                 row[keyword] = strArray[i];
                 table.Rows.Add(row);
                 row.AcceptChanges();
             }
         }
         return(true);
     }
 }
 internal string GetLiteralInfo(int literal)
 {
     using (IDBInfoWrapper wrapper = this.IDBInfo())
     {
         OleDbHResult result;
         System.Data.Common.UnsafeNativeMethods.IDBInfo dbInfo = wrapper.Value;
         if (dbInfo == null)
         {
             return(null);
         }
         string str          = null;
         IntPtr ptrZero      = ADP.PtrZero;
         int    literalCount = 0;
         using (new DualCoTaskMem(dbInfo, new int[] { literal }, out literalCount, out ptrZero, out result))
         {
             if (OleDbHResult.DB_E_ERRORSOCCURRED != result)
             {
                 if ((1 == literalCount) && (Marshal.ReadInt32(ptrZero, ODB.OffsetOf_tagDBLITERALINFO_it) == literal))
                 {
                     str = Marshal.PtrToStringUni(Marshal.ReadIntPtr(ptrZero, 0));
                 }
                 if (result < OleDbHResult.S_OK)
                 {
                     this.ProcessResults(result);
                 }
             }
             else
             {
                 SafeNativeMethods.Wrapper.ClearErrorInfo();
             }
         }
         return(str);
     }
 }
        internal string GetLiteralInfo(int literal)
        {
            using (IDBInfoWrapper wrapper = IDBInfo())
            {
                UnsafeNativeMethods.IDBInfo dbInfo = wrapper.Value;
                if (null == dbInfo)
                {
                    return(null);
                }
                string       literalValue = null;
                IntPtr       literalInfo  = ADP.PtrZero;
                int          literalCount = 0;
                OleDbHResult hr;

                using (DualCoTaskMem handle = new DualCoTaskMem(dbInfo, new int[1] {
                    literal
                }, out literalCount, out literalInfo, out hr))
                {
                    // All literals were either invalid or unsupported. The provider allocates memory for *prgLiteralInfo and sets the value of the fSupported element in all of the structures to FALSE. The consumer frees this memory when it no longer needs the information.
                    if (OleDbHResult.DB_E_ERRORSOCCURRED != hr)
                    {
                        if ((1 == literalCount) && Marshal.ReadInt32(literalInfo, ODB.OffsetOf_tagDBLITERALINFO_it) == literal)
                        {
                            literalValue = Marshal.PtrToStringUni(Marshal.ReadIntPtr(literalInfo, 0));
                        }
                        if (hr < 0)
                        { // ignore infomsg
                            ProcessResults(hr);
                        }
                    }
                    else
                    {
                        SafeNativeMethods.Wrapper.ClearErrorInfo();
                    }
                }
                return(literalValue);
            }
        }
        internal bool AddInfoKeywordsToTable(DataTable table, DataColumn keyword)
        {
            using (IDBInfoWrapper wrapper = IDBInfo()) {
                UnsafeNativeMethods.IDBInfo dbInfo = wrapper.Value;
                if (null == dbInfo)
                {
                    return(false);
                }

                OleDbHResult hr;
                string       keywords;

                Bid.Trace("<oledb.IDBInfo.GetKeywords|API|OLEDB> %d#\n", ObjectID);
                hr = dbInfo.GetKeywords(out keywords);
                Bid.Trace("<oledb.IDBInfo.GetKeywords|API|OLEDB|RET> %08X{HRESULT}\n", hr);

                if (hr < 0)   // ignore infomsg
                {
                    ProcessResults(hr);
                }

                if (null != keywords)
                {
                    string[] values = keywords.Split(new char[1] {
                        ','
                    });
                    for (int i = 0; i < values.Length; ++i)
                    {
                        DataRow row = table.NewRow();
                        row[keyword] = values[i];

                        table.Rows.Add(row);
                        row.AcceptChanges();
                    }
                }
                return(true);
            }
        }
        internal DataTable BuildInfoLiterals()
        {
            using (IDBInfoWrapper wrapper = IDBInfo())
            {
                UnsafeNativeMethods.IDBInfo dbInfo = wrapper.Value;
                if (null == dbInfo)
                {
                    return(null);
                }

                DataTable table = new DataTable("DbInfoLiterals");
                table.Locale = CultureInfo.InvariantCulture;
                DataColumn literalName  = new DataColumn("LiteralName", typeof(String));
                DataColumn literalValue = new DataColumn("LiteralValue", typeof(String));
                DataColumn invalidChars = new DataColumn("InvalidChars", typeof(String));
                DataColumn invalidStart = new DataColumn("InvalidStartingChars", typeof(String));
                DataColumn literal      = new DataColumn("Literal", typeof(Int32));
                DataColumn maxlen       = new DataColumn("Maxlen", typeof(Int32));

                table.Columns.Add(literalName);
                table.Columns.Add(literalValue);
                table.Columns.Add(invalidChars);
                table.Columns.Add(invalidStart);
                table.Columns.Add(literal);
                table.Columns.Add(maxlen);

                OleDbHResult hr;
                int          literalCount = 0;
                IntPtr       literalInfo  = ADP.PtrZero;
                using (DualCoTaskMem handle = new DualCoTaskMem(dbInfo, null, out literalCount, out literalInfo, out hr))
                {
                    // All literals were either invalid or unsupported. The provider allocates memory for *prgLiteralInfo and sets the value of the fSupported element in all of the structures to FALSE. The consumer frees this memory when it no longer needs the information.
                    if (OleDbHResult.DB_E_ERRORSOCCURRED != hr)
                    {
                        long             offset = literalInfo.ToInt64();
                        tagDBLITERALINFO tag    = new tagDBLITERALINFO();
                        for (int i = 0; i < literalCount; ++i, offset += ODB.SizeOf_tagDBLITERALINFO)
                        {
                            Marshal.PtrToStructure((IntPtr)offset, tag);

                            DataRow row = table.NewRow();
                            row[literalName]  = ((OleDbLiteral)tag.it).ToString();
                            row[literalValue] = tag.pwszLiteralValue;
                            row[invalidChars] = tag.pwszInvalidChars;
                            row[invalidStart] = tag.pwszInvalidStartingChars;
                            row[literal]      = tag.it;
                            row[maxlen]       = tag.cchMaxLen;

                            table.Rows.Add(row);
                            row.AcceptChanges();
                        }
                        if (hr < 0)
                        { // ignore infomsg
                            ProcessResults(hr);
                        }
                    }
                    else
                    {
                        SafeNativeMethods.Wrapper.ClearErrorInfo();
                    }
                }
                return(table);
            }
        }
 internal DataTable BuildInfoLiterals()
 {
     using (IDBInfoWrapper wrapper = this.IDBInfo())
     {
         OleDbHResult result;
         System.Data.Common.UnsafeNativeMethods.IDBInfo dbInfo = wrapper.Value;
         if (dbInfo == null)
         {
             return(null);
         }
         DataTable table = new DataTable("DbInfoLiterals")
         {
             Locale = CultureInfo.InvariantCulture
         };
         DataColumn column6 = new DataColumn("LiteralName", typeof(string));
         DataColumn column5 = new DataColumn("LiteralValue", typeof(string));
         DataColumn column4 = new DataColumn("InvalidChars", typeof(string));
         DataColumn column3 = new DataColumn("InvalidStartingChars", typeof(string));
         DataColumn column2 = new DataColumn("Literal", typeof(int));
         DataColumn column  = new DataColumn("Maxlen", typeof(int));
         table.Columns.Add(column6);
         table.Columns.Add(column5);
         table.Columns.Add(column4);
         table.Columns.Add(column3);
         table.Columns.Add(column2);
         table.Columns.Add(column);
         int    literalCount = 0;
         IntPtr ptrZero      = ADP.PtrZero;
         using (new DualCoTaskMem(dbInfo, null, out literalCount, out ptrZero, out result))
         {
             if (OleDbHResult.DB_E_ERRORSOCCURRED != result)
             {
                 long             num2      = ptrZero.ToInt64();
                 tagDBLITERALINFO structure = new tagDBLITERALINFO();
                 int num = 0;
                 while (num < literalCount)
                 {
                     Marshal.PtrToStructure((IntPtr)num2, structure);
                     DataRow row = table.NewRow();
                     row[column6] = ((OleDbLiteral)structure.it).ToString();
                     row[column5] = structure.pwszLiteralValue;
                     row[column4] = structure.pwszInvalidChars;
                     row[column3] = structure.pwszInvalidStartingChars;
                     row[column2] = structure.it;
                     row[column]  = structure.cchMaxLen;
                     table.Rows.Add(row);
                     row.AcceptChanges();
                     num++;
                     num2 += ODB.SizeOf_tagDBLITERALINFO;
                 }
                 if (result < OleDbHResult.S_OK)
                 {
                     this.ProcessResults(result);
                 }
             }
             else
             {
                 SafeNativeMethods.Wrapper.ClearErrorInfo();
             }
         }
         return(table);
     }
 }