当前位置: 首页>>代码示例>>C#>>正文


C# OleDbDataReader.GetName方法代码示例

本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.GetName方法的具体用法?C# OleDbDataReader.GetName怎么用?C# OleDbDataReader.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.OleDb.OleDbDataReader的用法示例。


在下文中一共展示了OleDbDataReader.GetName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDataTypes

        public static IDataType[] GetDataTypes(OleDbDataReader reader)
        {
            List<IDataType> types = new List<IDataType>();
            for (int i = 0; i < reader.FieldCount; i++)
            {
                if (reader.GetFieldType(i) == typeof(string))
                {
                    types.Add(new VarChar(reader.GetName(i), 1000));
                }
                else
                {
                    types.Add(new Number(reader.GetName(i)));
                }
            }

            return types.ToArray();
        }
开发者ID:azanium,项目名称:iShamelaV1-iOS,代码行数:17,代码来源:DbJet.cs

示例2: CreateDataTableColumns

 protected internal virtual void CreateDataTableColumns(DataTable dataTable, OleDbDataReader oleDbDataReader)
 {
     for (var i = 0; i < oleDbDataReader.FieldCount; i++)
     {
         var dataColumn = new DataColumn(oleDbDataReader.GetName(i));
         dataTable.Columns.Add(dataColumn);
     }
 }
开发者ID:puppylsy,项目名称:ClassSchedule2,代码行数:8,代码来源:DatabaseManager.cs

示例3: GetDataFieldNames

 public static string GetDataFieldNames(OleDbDataReader reader)
 {
     string dt = "";
     for (int i = 0; i < reader.FieldCount; i++)
     {
         dt = dt + "'"+reader.GetName(i)+"'";
         if (i < reader.FieldCount - 1)
         {
             dt = dt + ", ";
         }
     }
     return dt;
 }
开发者ID:azanium,项目名称:iShamelaV1-iOS,代码行数:13,代码来源:DbJet.cs

示例4: CreateColumnHeaders

        public void CreateColumnHeaders(OleDbDataReader Reader)
        {
            Columns.Clear();

            ColumnHeader[] ColumnHeaders = new ColumnHeader[Reader.FieldCount];

            for (int i = 0; i < ColumnHeaders.Length; i++)
            {
                ColumnHeaders[i] = new ColumnHeader();
                ColumnHeaders[i].Text = Reader.GetName(i);
                ColumnHeaders[i].Width  = (Width / ColumnHeaders.Length) * 9 / 10;
                Columns.Add(ColumnHeaders[i]);
            }
        }
开发者ID:bathla18,项目名称:Web-log-analyser-cross-platform,代码行数:14,代码来源:QueryListView.cs

示例5: OrgReturnNode

    public static string OrgReturnNode(string subNodeName,string sNodeName,OleDbDataReader rst)
    {
      XmlDocument doc = XmlFun.CreateNewDoc("<" + subNodeName + "/>");
      XmlElement el_row = null;
      XmlElement elem = null;

      while (rst.Read()) // 循环获取记录集的值
      {
        el_row = doc.CreateElement(sNodeName);

        for (int i = 0; i < rst.FieldCount; i++)
        {
          string strFieldName = rst.GetName(i).ToUpper();
          string sValue = rst[i].ToString();

          elem = doc.CreateElement(strFieldName);
          elem.InnerText = sValue;

          el_row.AppendChild(elem);
        }
        doc.DocumentElement.AppendChild(el_row);
      }

      el_row = null;
      elem = null;
      return doc.InnerXml;
    }
开发者ID:windygu,项目名称:asxinyunet,代码行数:27,代码来源:ReturnDoc.cs

示例6: ReadItem

        private PivotItem ReadItem(OleDbDataReader dataReader, int rowId)
        {
            PivotItem item = new PivotItem(rowId.ToString(), this);

            for (int column = 0; column < dataReader.FieldCount; column++)
            {
                if (dataReader.IsDBNull(column)) continue;

                String columnName = dataReader.GetName(column).ToLowerInvariant();
                String value = dataReader.GetValue(column).ToString();
                if (String.IsNullOrEmpty(value)) continue;

                if (columnName == OleDbSchemaConstants.Item.Name)
                {
                    item.Name = value;
                }
                else if (columnName == OleDbSchemaConstants.Item.Image)
                {
                    String imagePath = UriUtility.ExpandRelativeUri(this.BasePath, value);
                    item.Image = new PivotImage(imagePath);
                }
                else if (columnName == OleDbSchemaConstants.Item.Description)
                {
                    item.Description = value;
                }
                else if (columnName == OleDbSchemaConstants.Item.Href)
                {
                    item.Href = value;
                }
                else if (columnName == OleDbSchemaConstants.Item.RelatedLinks)
                {
                    StringReader valueReader = new StringReader(value);
                    String singleValue = null;
                    while ((singleValue = valueReader.ReadLine()) != null)
                    {
                        String[] parts = singleValue.Split(
                            new String[] { OleDbSchemaConstants.LinkPartDelimiter }, StringSplitOptions.None);
                        if (parts.Length > 0)
                        {
                            String name = null, url = null;
                            if (parts.Length == 1)
                            {
                                url = parts[0];
                            }
                            else if (parts.Length >= 2)
                            {
                                name = parts[0];
                                url = parts[1];
                            }
                            item.AddRelatedLink(new PivotLink(name, url));
                        }
                    }
                }
                else
                {
                    PivotFacetCategory facetCategory = null;
                    foreach (PivotFacetCategory currentFacetCategory in m_facetCategoryMap.Values)
                    {
                        if (columnName == currentFacetCategory.Name.Replace('.', '#').ToLowerInvariant())
                        {
                            facetCategory = currentFacetCategory;
                            break;
                        }
                    }

                    if (facetCategory != null)
                    {
                        item.AddFacetValues(facetCategory.Name, this.SplitJoinedStrings(value).ToArray());
                    }
                }
            }

            return item;
        }
开发者ID:saviourofdp,项目名称:pauthor,代码行数:74,代码来源:OleDbCollectionSource.cs

示例7: CreateFacetCategory

        private PivotFacetCategory CreateFacetCategory(OleDbDataReader dataReader)
        {
            String name = null;
            PivotFacetType type = null;

            for (int column = 0; column < dataReader.FieldCount; column++)
            {
                if (dataReader.IsDBNull(column)) continue;

                String columnName = dataReader.GetName(column).ToLowerInvariant();
                String value = dataReader.GetValue(column).ToString();

                if (columnName == OleDbSchemaConstants.FacetCategory.Name)
                {
                    name = value;
                }
                else if (columnName == OleDbSchemaConstants.FacetCategory.Type)
                {
                    type = PivotFacetType.Parse(value);
                }
            }
            if (name == null) throw new InvalidDataException("Facet Categories data set is missing a Name column");
            if (type == null) throw new InvalidDataException("Facet Categories data set is missing a Type column");
            return new PivotFacetCategory(name, type);
        }
开发者ID:saviourofdp,项目名称:pauthor,代码行数:25,代码来源:OleDbCollectionSource.cs

示例8: DisplayReader

        // Display the result set recursively expanding chapterDepth deep
        public void DisplayReader(OleDbDataReader myDataReader, ref uint count, uint alignment, int chapterDepth)
        {
            try
            {
                // compute alignment
                StringBuilder indent = new StringBuilder((int) alignment);
                indent.Append(' ', (int) alignment);

                while (myDataReader.Read())
                {
                    // add alignment
                    StringBuilder row = new StringBuilder(indent.ToString());

                    // for all columns
                    for (int i = 0; i < myDataReader.FieldCount; i++)
                    {
                        // null columns
                        if (myDataReader.IsDBNull(i))
                        {
                            row.Append("NULL;");
                        }
                        else
                        {

                            //vector columns
                            object[] myArray = myDataReader.GetValue(i) as object[];
                            if (myArray != null)
                            {
                                DisplayValue(myArray, row);
                            }
                            else
                            {
                                //check for chapter columns from "group on" queries
                                if (myDataReader.GetFieldType(i).ToString() != "System.Data.IDataReader")
                                {
                                    //regular columns are displayed here
                                    row.Append(myDataReader.GetValue(i));
                                }
                                else
                                {
                                    //for a chapter column type just display the colum name
                                    row.Append(myDataReader.GetName(i));
                                }
                            }
                            row.Append(';');
                        }
                    }
                    if (chapterDepth >= 0)
                    {
                        this.ScrubberGUIInst.DebugPrint(row.ToString());
                        count++;
                    }
                    // for each chapter column
                    for (int i = 0; i < myDataReader.FieldCount; i++)
                    {
                        if (myDataReader.GetFieldType(i).ToString() == "System.Data.IDataReader")
                        {
                            OleDbDataReader Reader = myDataReader.GetValue(i) as OleDbDataReader;
                            DisplayReader(Reader, ref count, alignment + 8, chapterDepth - 1);
                        }
                    }
                }
            }
            finally
            {
                myDataReader.Close();
                myDataReader.Dispose();
            }
        }
开发者ID:solbirn,项目名称:Scrubber,代码行数:70,代码来源:WindowsSearchCleaner.cs

示例9: Transfer

        /// <summary>
        /// Transfere dados do banco de dados atual para um banco de dados de destino.
        /// Conexão com o banco de destino precisa estar aberta.
        /// </summary>
        /// <returns>Número de linhas transferidas.</returns>
        /// <param name="p_query">Consulta SQL para buscar os dados no banco atual.</param>
        /// <param name="p_insert">Comando de inserção para inserir cada linha no banco de destino.</param>
        /// <param name="p_destdatabase">Conexão com o banco de destino.</param>
        public override uint Transfer(string p_query, Spartacus.Database.Command p_insert, Spartacus.Database.Generic p_destdatabase)
        {
            uint v_transfered = 0;

            if (this.v_con == null)
            {
                try
                {
                    this.v_con = new System.Data.OleDb.OleDbConnection(this.v_connectionstring);
                    this.v_con.Open();
                    this.v_cmd = new System.Data.OleDb.OleDbCommand(p_query, this.v_con);
                    this.v_reader = this.v_cmd.ExecuteReader();

                    while (v_reader.Read())
                    {
                        for (int i = 0; i < v_reader.FieldCount; i++)
                            p_insert.SetValue(this.FixColumnName(v_reader.GetName(i)).ToLower(), v_reader[i].ToString());

                        p_destdatabase.Execute(p_insert.GetUpdatedText());
                        v_transfered++;
                    }

                    return v_transfered;
                }
                catch (System.Data.OleDb.OleDbException e)
                {
                    throw new Spartacus.Database.Exception(e);
                }
                finally
                {
                    if (this.v_reader != null)
                    {
                        this.v_reader.Close();
                        this.v_reader = null;
                    }
                    if (this.v_cmd != null)
                    {
                        this.v_cmd.Dispose();
                        this.v_cmd = null;
                    }
                    if (this.v_con != null)
                    {
                        this.v_con.Close();
                        this.v_con = null;
                    }
                }
            }
            else
            {
                try
                {
                    this.v_cmd.CommandText = p_query;
                    this.v_reader = this.v_cmd.ExecuteReader();

                    while (v_reader.Read())
                    {
                        for (int i = 0; i < v_reader.FieldCount; i++)
                            p_insert.SetValue(this.FixColumnName(v_reader.GetName(i)).ToLower(), v_reader[i].ToString());

                        p_destdatabase.Execute(p_insert.GetUpdatedText());
                        v_transfered++;
                    }

                    return v_transfered;
                }
                catch (System.Data.OleDb.OleDbException e)
                {
                    throw new Spartacus.Database.Exception(e);
                }
                finally
                {
                    if (this.v_reader != null)
                    {
                        this.v_reader.Close();
                        this.v_reader = null;
                    }
                }
            }
        }
开发者ID:lubota,项目名称:spartacus,代码行数:87,代码来源:Spartacus.Database.Oledb.cs

示例10: Reader2Criterias

 private List<SingleIndexCriteria> Reader2Criterias(OleDbDataReader reader)
 {
     if (reader==null)
        {
        return null;
        }
     if(reader.IsClosed)
     {
         throw (new Exception("Reader is closed!"));
     }
     List<SingleIndexCriteria> criterias = new List<SingleIndexCriteria>();
     while(reader.Read())
     {
         SingleIndexCriteria singleCriteria = new SingleIndexCriteria();
         for(int fieldCounter=0;fieldCounter<reader.FieldCount;fieldCounter++)
         {
             switch(reader.GetName(fieldCounter))
             {
                 case fieldProjectName:
                     singleCriteria.ProjectName = reader[fieldCounter].ToString();
                     break;
                 case fieldIndexName:
                     singleCriteria.IndexName = reader[fieldCounter].ToString();
                     break;
                 case fieldLevelType:
                     singleCriteria.LevelType = int.Parse(reader[fieldCounter].ToString());
                     break;
                 case fieldCriterias:
                     singleCriteria.CriteriaValues = ConvertCriterias2DivideValue(reader[fieldCounter].ToString());
                     break;
                 case fieldIsAbsolute:
                     singleCriteria.IsAbsolute = bool.Parse(reader[fieldCounter].ToString());
                     break;
                 default:
                     throw(new Exception("unexpected field!"));
             }
         }
         criterias.Add(singleCriteria);
     }
     reader.Close();
     dbConn.Close();
     return criterias;
 }
开发者ID:zeuscn,项目名称:ShieldTunnelHealthEvaluation,代码行数:43,代码来源:TableCriteriaUtil.cs

示例11: DisplayReader

        // Display the result set recursively expanding chapterDepth deep
        static void DisplayReader(OleDbDataReader myDataReader, ref uint count, uint alignment, int chapterDepth)
        {
            try
            {
                // compute alignment
                StringBuilder indent = new StringBuilder((int)alignment);
                indent.Append(' ', (int)alignment);

                while (myDataReader.Read())
                {
                    // add alignment
                    StringBuilder row = new StringBuilder(indent.ToString());

                    // for all columns
                    for (int i = 0; i < myDataReader.FieldCount; i++)
                    {
                        // null columns
                        if (myDataReader.IsDBNull(i))
                        {
                            row.Append("NULL\t");
                        }
                        else
                        {
                            //vector columns
                            object[] myArray = myDataReader.GetValue(i) as object[];
                            if (myArray != null)
                            {
                                DisplayValue(myArray, row);
                            }
                            else
                            {
                                //check for chapter columns from "group on" queries
                                if (myDataReader.GetFieldType(i).ToString() != "System.Data.IDataReader")
                                {
                                    //regular columns are displayed here
                                    //If (OptPath == false) and colName is System.ItemPathDisplay
                                    //We want to skip Display of this Column
                                    if (!(OptPath == false && myDataReader.GetName(i) == "System.ItemPathDisplay"))
                                        row.Append(myDataReader.GetValue(i));
                                }
                                else
                                {
                                    //for a chapter column type just display the colum name
                                    row.Append(myDataReader.GetName(i));
                                }
                            }
                            row.Append('\t');
                        }
                    }
                    if (chapterDepth >= 0)
                    {
                        Console.WriteLine(row.ToString());
                        count++;
                    }
                    // for each chapter column
                    for (int i = 0; i < myDataReader.FieldCount; i++)
                    {
                        if (myDataReader.GetFieldType(i).ToString() == "System.Data.IDataReader")
                        {
                            OleDbDataReader Reader = myDataReader.GetValue(i) as OleDbDataReader;
                            DisplayReader(Reader, ref count, alignment + 8, chapterDepth - 1);
                        }
                    }
                }
            }
            finally
            {
                myDataReader.Close();
                myDataReader.Dispose();
            }
        }
开发者ID:Grynn,项目名称:locate,代码行数:72,代码来源:Program.cs

示例12: AddFromReader

  public void AddFromReader(OleDbDataReader reader, bool addSpace)
  {
    do
    {
      if (reader.HasRows)
      {
        HtmlGenericControl resultSetDiv = CreateDiv("ResultSet");
        _container.Controls.Add(resultSetDiv);

        int headerColumn = reader.GetColumnIndex("Header");
        string lastHeader = null;
        
        int subheaderColumn = reader.GetColumnIndex("Subheader");
        string lastSubHeader = null;
        
        int lastColumn = reader.FieldCount - 1;

        for (int i = 0; i < 2; ++i)
        {
          if (lastColumn == headerColumn || lastColumn == subheaderColumn)
          {
            lastColumn -= 1;
          }
        }

        while (reader.Read())
        {
          HtmlGenericControl rowSetDiv = CreateDiv("RowSet");
          resultSetDiv.Controls.Add(rowSetDiv);

          bool headerAdded = false;
          bool subheaderAdded = false;

          if (headerColumn >= 0 && !reader.IsDBNull(headerColumn))
          {
            string header = reader.GetValue(headerColumn).ToString();
            headerAdded = header != lastHeader;

            if (headerAdded)
            {
              HtmlGenericControl headerDiv = CreateDiv("RowSetHeader", header);
              rowSetDiv.Controls.Add(headerDiv);
              lastHeader = header;
            }
          }

          if (subheaderColumn >= 0 && !reader.IsDBNull(subheaderColumn))
          {
            string subheader = reader.GetValue(subheaderColumn).ToString();
            subheaderAdded = subheader != lastSubHeader;

            if (subheaderAdded)
            {
              if (headerAdded && addSpace)
              {
                AddSpace(rowSetDiv, "Space2");
              }

              HtmlGenericControl subheaderDiv = CreateDiv("RowSetSubheader", subheader);
              rowSetDiv.Controls.Add(subheaderDiv);
              lastSubHeader = subheader;
            }
          }

          if (lastColumn < 0)
          {
            if (addSpace)
            {
              AddSpace(rowSetDiv, "Space2");
            }
          }
          else
          {
            if ((headerAdded || subheaderAdded) && addSpace)
            {
              AddSpace(rowSetDiv, "Space2");
            }

            for (int i = 0; i < reader.FieldCount; ++i)
            {
              if (i != headerColumn && i != subheaderColumn)
              {
                HtmlGenericControl valueSetDiv = CreateDiv("ValueSet");
                rowSetDiv.Controls.Add(valueSetDiv);

                HtmlGenericControl labelDiv = CreateDiv("Label", reader.GetName(i));
                valueSetDiv.Controls.Add(labelDiv);

                if (addSpace)
                {
                  HtmlGenericControl separatorDiv = CreateDiv("Separator", "");
                  valueSetDiv.Controls.Add(separatorDiv);
                }

                HtmlGenericControl valueDiv = CreateValueDiv(!reader.IsDBNull(i) ? reader.GetValue(i) : null);
                valueSetDiv.Controls.Add(valueDiv);

                if (i < lastColumn && addSpace)
                {
                  AddSpace(rowSetDiv, "Space1");
//.........这里部分代码省略.........
开发者ID:ClaireBrill,项目名称:GPV,代码行数:101,代码来源:DataListBuilder.cs

示例13: Load

        /// <summary>
        /// Load from database by OleDbDataReader - used to load a single record
        /// </summary>
        public void Load(OleDbDataReader dataReader)
        {
            for(int i=0; i<dataReader.FieldCount; i++)
            {
                DBField field = m_fields[(int)m_lookup[dataReader.GetName(i)]];
                field.Value = dataReader[field.Name]; //(null == dataReader[field.Name]) ? null : dataReader[field.Name];
            }

            SetUpdateWhereClause();

            m_isNew = false;
        }
开发者ID:beaujackson,项目名称:Checkbook,代码行数:15,代码来源:BaseRecord.cs

示例14: ReadDataIntoDataTable

 protected internal virtual void ReadDataIntoDataTable(DataTable dataTable, OleDbDataReader oleDbDataReader)
 {
     while (oleDbDataReader.Read())
     {
         var dataRow = dataTable.NewRow();
         for (var i = 0; i < oleDbDataReader.FieldCount; i++)
         {
             dataRow[oleDbDataReader.GetName(i)] = oleDbDataReader[oleDbDataReader.GetName(i)].ToString();
         }
         dataTable.Rows.Add(dataRow);
     }
 }
开发者ID:puppylsy,项目名称:ClassSchedule2,代码行数:12,代码来源:DatabaseManager.cs

示例15: InsertRowString

        private static string InsertRowString(string tableName, Dictionary<string, string> valueDict, OleDbDataReader read)
        {
            var sb = new StringBuilder();
            //bool firstcol = true;
            sb.AppendFormat("INSERT INTO [{0}](", tableName);

            for (int i = 0; i < read.FieldCount; ++i)
            {
                if (i != 0)
                {
                    sb.Append(",");
                }
                sb.Append(read.GetName(i));
            }

            sb.Append(") VALUES(");
            for (int i = 0; i < read.FieldCount; ++i)
            {
                sb.Append("@" + read.GetName(i));
                if (i != read.FieldCount - 1)
                {
                    sb.Append(",");
                }
            }
            sb.Append(")");
            return sb.ToString();
        }
开发者ID:AzarinSergey,项目名称:learn,代码行数:27,代码来源:ExcelHelper.cs


注:本文中的System.Data.OleDb.OleDbDataReader.GetName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。