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


C# DbDataReader.NextResult方法代码示例

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


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

示例1: DisplayRows

        public void DisplayRows(DbDataReader nt)
        {
            this.listView1.Clear();

            for (int i = 0; i < nt.FieldCount; i++)
            {
                listView1.Columns.Add(nt.GetName(i));
            }
            int rowCount = 0;
            while (nt.NextResult())
            {
                rowCount++;
                string contents = "";

                if (nt[0] != null)
                {
                    contents = nt[0].ToString();
                }

                ListViewItem lvi = new ListViewItem(contents);
                for (int i = 1; i < nt.FieldCount; i++)
                {
                    contents = "";
                    if (nt[i] != null)
                    {
                        contents = nt[i].ToString();
                    }
                    lvi.SubItems.Add(contents);
                }
                this.listView1.Items.Add(lvi);
            }
            this.toolStripStatusLabel1.Text = rowCount.ToString() + " row(s) returned.";
        }
开发者ID:buttonpusher,项目名称:NetBase,代码行数:33,代码来源:Form1.cs

示例2: Consume

        protected override void Consume(DbDataReader reader)
        {
            Debug.Assert(CommandResultSet.Count == ModificationCommands.Count);
            var commandIndex = 0;

            try
            {
                var actualResultSetCount = 0;
                do
                {
                    while (commandIndex < CommandResultSet.Count
                           && CommandResultSet[commandIndex] == ResultSetMapping.NoResultSet)
                    {
                        commandIndex++;
                    }

                    if (commandIndex < CommandResultSet.Count)
                    {
                        commandIndex = ModificationCommands[commandIndex].RequiresResultPropagation
                            ? ConsumeResultSetWithPropagation(commandIndex, reader)
                            : ConsumeResultSetWithoutPropagation(commandIndex, reader);
                        actualResultSetCount++;
                    }
                }
                while (commandIndex < CommandResultSet.Count
                       && reader.NextResult());

#if DEBUG
                while (commandIndex < CommandResultSet.Count
                       && CommandResultSet[commandIndex] == ResultSetMapping.NoResultSet)
                {
                    commandIndex++;
                }

                Debug.Assert(commandIndex == ModificationCommands.Count,
                    "Expected " + ModificationCommands.Count + " results, got " + commandIndex);

                var expectedResultSetCount = CommandResultSet.Count(e => e == ResultSetMapping.LastInResultSet);

                Debug.Assert(actualResultSetCount == expectedResultSetCount,
                    "Expected " + expectedResultSetCount + " result sets, got " + actualResultSetCount);
#endif
            }
            catch (DbUpdateException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new DbUpdateException(
                    RelationalStrings.UpdateStoreException,
                    ex,
                    ModificationCommands[commandIndex].Entries);
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:55,代码来源:AffectedCountModificationCommandBatch.cs

示例3: ConsumeReader

 /// <summary>
 ///     Consumes all rows and result sets from the reader. This allows client to retrieve
 ///     parameter values and intercept any store exceptions.
 /// </summary>
 /// <param name="reader"> Reader to consume. </param>
 internal static void ConsumeReader(DbDataReader reader)
 {
     if (null != reader
         && !reader.IsClosed)
     {
         while (reader.NextResult())
         {
             // Note that we only walk through the result sets. We don't need
             // to walk through individual rows (though underlying provider
             // implementation may do so)
         }
     }
 }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:18,代码来源:CommandHelper.cs

示例4: Consume

        protected override void Consume(DbDataReader reader, DbContext context)
        {
            Debug.Assert(ResultSetEnds.Count == ModificationCommands.Count);
            var commandIndex = 0;

            try
            {
                var actualResultSetCount = 0;
                do
                {
                    commandIndex = ModificationCommands[commandIndex].RequiresResultPropagation
                        ? ConsumeResultSetWithPropagation(commandIndex, reader, context)
                        : ConsumeResultSetWithoutPropagation(commandIndex, reader, context);
                    actualResultSetCount++;
                }
                while (commandIndex < ResultSetEnds.Count
                       && reader.NextResult());

                Debug.Assert(commandIndex == ModificationCommands.Count,
                    "Expected " + ModificationCommands.Count + " results, got " + commandIndex);
#if DEBUG
                var expectedResultSetCount = 1 + ResultSetEnds.Count(e => e);
                expectedResultSetCount += ResultSetEnds[ResultSetEnds.Count - 1] ? -1 : 0;

                Debug.Assert(actualResultSetCount == expectedResultSetCount,
                    "Expected " + expectedResultSetCount + " result sets, got " + actualResultSetCount);
#endif
            }
            catch (DbUpdateException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new DbUpdateException(
                    Strings.UpdateStoreException,
                    ex,
                    ModificationCommands[commandIndex].Entries);
            }
        }
开发者ID:rbenhassine2,项目名称:EntityFramework,代码行数:40,代码来源:AffectedCountModificationCommandBatch.cs

示例5: BuildProfileInfoCollection

		ProfileInfoCollection BuildProfileInfoCollection (DbDataReader reader, out int totalRecords)
		{
			ProfileInfoCollection pic = new ProfileInfoCollection ();
			while (reader.Read ()) {
				ProfileInfo pi = ReadProfileInfo (reader);
				if (pi != null)
					pic.Add (pi);
			}
			totalRecords = 0;
			if (reader.NextResult ()) {
				if (reader.Read ())
					totalRecords = reader.GetInt32 (0);
			}
			return pic;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:SqlProfileProvider.cs

示例6: ReadDataMulti

        static void ReadDataMulti(DbDataReader reader)
        {
            var ctr = 1;
            while (reader.HasRows)
            {
                while (reader.Read())
                {
                    Console.WriteLine(ctr == 1
                        ? string.Format("\nExpected - {0} , Got - {1}", "sfk shan", reader.Get<string>("Name")) //First result set - Employee
                        : string.Format("\nExpected - {0} , Got - {1}", "HR", reader.Get<string>("name")));//Second Result set - Department

                    break;
                }
                ctr++;
                reader.NextResult();
            }
            //Note : for test purpose it is skipped to iterate the rest rows
        }
开发者ID:alex-yqli,项目名称:DbConnect,代码行数:18,代码来源:Program.Test.NonMappingMethods.cs

示例7: Convert_Facet_Tables_To_Facet_Lists

        private void Convert_Facet_Tables_To_Facet_Lists(DbDataReader Reader, List<short> Facet_Types)
        {
            // Go to the next table
            if (!Reader.NextResult())
                return;

            // Incrementor going through tables (and skipping aggregation table maybe)
            if (Reader.FieldCount > 2)
            {
                // Read all the aggregation fields
                while (Reader.Read())
                {
                    Aggregation_Facets.Add(new Search_Facet_Aggregation(Reader.GetString(1), Reader.GetInt32(2), Reader.GetString(0)));
                }

                if (!Reader.NextResult())
                    return;
            }

            // Add all the other facets, reading each subsequent table in the results
            int current_facet_index = 0;
            do
            {
                // Build this facet list
                if ((Reader.FieldCount == 2) && (Facet_Types.Count > current_facet_index))
                {
                    // Create the collection and and assifn the metadata type id
                    Search_Facet_Collection thisCollection = new Search_Facet_Collection(Facet_Types[current_facet_index]);

                    // Read all the individual facet values
                    while (Reader.Read())
                    {
                        thisCollection.Facets.Add(new Search_Facet(Reader.GetString(0), Reader.GetInt32(1)));
                    }

                    // If there was an id and facets added, save this to the search statistics
                    if ((thisCollection.MetadataTypeID > 0) && (thisCollection.Facets.Count > 0))
                    {
                        Facet_Collections.Add(thisCollection);
                    }
                }

                current_facet_index++;
            } while (Reader.NextResult());
        }
开发者ID:Elkolt,项目名称:SobekCM-Web-Application,代码行数:45,代码来源:Search_Results_Statistics.cs

示例8: GetSchemaResultsetsFromReader

		/// <summary>
		/// Execute a command against a data source, mapping the data reader GetSchemaTable() result to an enumerable of resultsets, each with an enumerable of records dictionaries.
		/// This method perfoms LAZY LOADING/DEFERRED EXECUTION.
		/// </summary>
		/// <param name="dbDataReader"> The target data reader. </param>
		/// <returns> An enumerable of resultset instances, each containing an enumerable of dictionaries with record key/value pairs of schema metadata. </returns>
		public IEnumerable<IResultset> GetSchemaResultsetsFromReader(DbDataReader dbDataReader)
		{
			int resultsetIndex = 0;

			OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): enter", typeof(AdoNetStreamingFascade).Name));

			if ((object)dbDataReader == null)
				throw new ArgumentNullException(nameof(dbDataReader));

			OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): before yield", typeof(AdoNetStreamingFascade).Name));

			using (dbDataReader)
			{
				OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): use reader", typeof(AdoNetStreamingFascade).Name));

				do
				{
					Resultset resultset = new Resultset(resultsetIndex++); // prevent modified closure
					resultset.Records = this.GetSchemaRecordsFromReader(dbDataReader, (ra) => resultset.RecordsAffected = ra);

					OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): on yield", typeof(AdoNetStreamingFascade).Name));

					yield return resultset; // LAZY PROCESSING INTENT HERE / DO NOT FORCE EAGER LOAD
				}
				while (dbDataReader.NextResult());

				OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): dispose reader", typeof(AdoNetStreamingFascade).Name));
			}

			OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): after yield", typeof(AdoNetStreamingFascade).Name));

			OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): leave", typeof(AdoNetStreamingFascade).Name));
		}
开发者ID:textmetal,项目名称:main,代码行数:39,代码来源:AdoNetStreamingFascade.cs

示例9: DataReader_To_Simple_Result_List2

        private static List<iSearch_Title_Result> DataReader_To_Simple_Result_List2(DbDataReader Reader, List<string> MetadataFieldNames)
        {
            // Create return list
            List<iSearch_Title_Result> returnValue = new List<iSearch_Title_Result>();

            // Create some lists used during the construction
            Dictionary<int, Database_Title_Result> titleLookupByRowNumber = new Dictionary<int, Database_Title_Result>();
            Dictionary<int, Database_Item_Result> itemLookupByItemID = new Dictionary<int, Database_Item_Result>();
            Dictionary<int, int> rowNumberLookupByItemID = new Dictionary<int, int>();

            // May have not values returned
            if (Reader.FieldCount < 5)
                return null;

            // Get all the main title values first
            int minimumRownumber = -1;
            while (Reader.Read())
            {
                // Create new database title object for this
                Database_Title_Result result = new Database_Title_Result
                {
                    RowNumber = Reader.GetInt32(0),
                    BibID = Reader.GetString(1),
                    GroupTitle = Reader.GetString(2),
                    OPAC_Number = Reader.GetInt32(3),
                    OCLC_Number = Reader.GetInt64(4),
                    GroupThumbnail = Reader.GetString(5),
                    MaterialType = Reader.GetString(6),
                    Primary_Identifier_Type = Reader.GetString(7),
                    Primary_Identifier = Reader.GetString(8)
                };

                titleLookupByRowNumber.Add(result.RowNumber, result);

                if (minimumRownumber == -1)
                {
                    minimumRownumber = result.RowNumber;
                }
            }

            // Move to the item system-required information table
            Reader.NextResult();

            // If there were no titles, then there are no results
            if (titleLookupByRowNumber.Count == 0)
                return returnValue;

            // Step through all the item rows, build the item, and add to the title
            Database_Title_Result titleResult = titleLookupByRowNumber[minimumRownumber];
            returnValue.Add(titleResult);
            int lastRownumber = titleResult.RowNumber;
            while (Reader.Read())
            {
                // Ensure this is the right title for this item
                int thisRownumber = Reader.GetInt32(0);
                if (thisRownumber != lastRownumber)
                {
                    titleResult = titleLookupByRowNumber[thisRownumber];
                    lastRownumber = thisRownumber;

                    // Add this title to the list
                    returnValue.Add(titleResult);
                }

                // Create new database item object for this
                Database_Item_Result result = new Database_Item_Result
                {
                    ItemID = Reader.GetInt32(1),
                    VID = Reader.GetString(2),
                    Title = Reader.GetString(3),
                    IP_Restriction_Mask = Reader.GetInt16(4),
                    MainThumbnail = Reader.GetString(5),
                    Level1_Index = (short)Reader.GetInt32(6),
                    Level1_Text = Reader.GetString(7),
                    Level2_Index = (short)Reader.GetInt32(8),
                    Level2_Text = Reader.GetString(9),
                    Level3_Index = (short)Reader.GetInt32(10),
                    Level3_Text = Reader.GetString(11),
                    PubDate = Reader.GetString(12),
                    PageCount = Reader.GetInt32(13),
                    Link = Reader.GetString(14),
                    Spatial_KML = Reader.GetString(15),
                    COinS_OpenURL = Reader.GetString(16)
                };

                // Save to the hash lookup for adding display metadata
                itemLookupByItemID[result.ItemID] = result;
                rowNumberLookupByItemID[result.ItemID] = thisRownumber;

                // Add this to the title object
                titleResult.Add_Item_Result(result);
            }

            // Move to the item aggregation-configured display information table
            Reader.NextResult();

            // Set some values for checking for uniformity of values
            const int ITEMS_TO_CHECK_IN_EACH_TITLE = 20;
            bool first_item_analyzed = true;
            List<bool> checking_fields = new List<bool>();
//.........这里部分代码省略.........
开发者ID:MarkVSullivan,项目名称:SobekCM-Web-Application,代码行数:101,代码来源:Engine_Database.cs

示例10: DataReader_To_Private_Items_List

        private static List<Private_Items_List_Title> DataReader_To_Private_Items_List(DbDataReader Reader)
        {
            // Create return list
            List<Private_Items_List_Title> returnValue = new List<Private_Items_List_Title>();

            Dictionary<int, int> lookup = new Dictionary<int, int>();

            // Get all the main title values first
            while (Reader.Read())
            {
                // Create new database title object for this
                Private_Items_List_Title result = new Private_Items_List_Title
                {
                    RowNumber = Reader.GetInt32(0),
                    BibID = Reader.GetString(1),
                    Group_Title = Reader.GetString(2),
                    Type = Reader.GetString(3),
                    LastActivityDate = Reader.GetDateTime(6),
                    LastMilestoneDate = Reader.GetDateTime(7),
                    CompleteItemCount = Reader.GetInt32(8),
                    PrimaryIdentifierType = Reader.GetString(9),
                    PrimaryIdentifier = Reader.GetString(10)
                };

                returnValue.Add(result);

                lookup.Add(result.RowNumber, returnValue.Count - 1);
            }

            // Move to the item table
            Reader.NextResult();

            // If there were no titles, then there are no results
            if (returnValue.Count == 0)
                return returnValue;

            // Step through all the item rows, build the item, and add to the title
            Private_Items_List_Title titleResult = returnValue[0];
            int lastRownumber = titleResult.RowNumber;
            while (Reader.Read())
            {
                // Ensure this is the right title for this item
                int thisRownumber = Reader.GetInt32(0);
                if (thisRownumber != lastRownumber)
                {
                    titleResult = returnValue[lookup[thisRownumber]];
                    lastRownumber = thisRownumber;
                }

                // Create new database item object for this
                Private_Items_List_Item result = new Private_Items_List_Item
                {
                    VID = Reader.GetString(1),
                    Title = Reader.GetString(2),
                    LocallyArchived = Reader.GetBoolean(5),
                    RemotelyArchived = Reader.GetBoolean(6),
                    AggregationCodes = Reader.GetString(7),
                    LastActivityDate = Reader.GetDateTime(8),
                    LastActivityType = Reader.GetString(9),
                    LastMilestone = Reader.GetInt32(10),
                    LastMilestoneDate = Reader.GetDateTime(11)
                };

                // Pull the values that are nullable
                string comments = Reader.GetString(3);
                string pubdate = Reader.GetString(4);

                string creator = Reader.GetString(19);

                // Assign the values if there are values
                if (comments.Length > 0) result.Internal_Comments = comments;
                if (pubdate.Length > 0) result.PubDate = pubdate;
                if (creator.Length > 0) result.Creator = creator;

                // Assign the embargo end
                if (!Reader.IsDBNull(18))
                {
                    DateTime embargoEnd = Reader.GetDateTime(18);
                    if (embargoEnd.Year < 9999)
                        result.EmbargoDate = embargoEnd;
                }

                // Add this to the title object
                titleResult.Add_Item_Result(result);
            }

            return returnValue;
        }
开发者ID:MarkVSullivan,项目名称:SobekCM-Web-Application,代码行数:88,代码来源:Engine_Database.cs

示例11: OutputRmlTable

        // 输出 RML 格式的表格
        // 本函数负责写入 <table> 元素
        // parameters:
        //      nTopLines   顶部预留多少行
        void OutputRmlTable(
            DbDataReader data_reader,
            XmlTextWriter writer,
            int nMaxLines = -1)
        {
            // StringBuilder strResult = new StringBuilder(4096);
            int i, j;

#if NO
            if (nMaxLines == -1)
                nMaxLines = table.Count;
#endif

            writer.WriteStartElement("table");
            WriteAttributeString(writer, "class", "table");

            writer.WriteStartElement("thead");
            writer.WriteStartElement("tr");

            int nEvalCount = 0; // 具有 eval 的栏目个数
            for (j = 0; j < this.Columns.Count; j++)
            {
                PrintColumn000 column = this.Columns[j];
                if (column.Colspan == 0)
                    continue;

                if (string.IsNullOrEmpty(column.Eval) == false)
                    nEvalCount++;

                writer.WriteStartElement("th");
                if (string.IsNullOrEmpty(column.CssClass) == false)
                    WriteAttributeString(writer, "class", column.CssClass);
                if (column.Colspan > 1)
                    WriteAttributeString(writer, "colspan", column.Colspan.ToString());

                WriteString(writer, column.Title);
                writer.WriteEndElement();   // </th>
            }

            writer.WriteEndElement();   // </tr>
            writer.WriteEndElement();   // </thead>

            // 合计数组
            object[] sums = null;   // 2008/12/1 new changed

            if (this.SumLine)
            {
                sums = new object[this.Columns.Count];
                for (i = 0; i < sums.Length; i++)
                {
                    sums[i] = null;
                }
            }

            NumberFormatInfo nfi = new CultureInfo("zh-CN", false).NumberFormat;
            nfi.NumberDecimalDigits = 2;

            writer.WriteStartElement("tbody");

            // Jurassic.ScriptEngine engine = null;
            if (nEvalCount > 0 && engine == null)
            {
                engine = new Jurassic.ScriptEngine();
                engine.EnableExposedClrTypes = true;
            }

            int nLineCount = 0;

            // 内容行循环
            for (i = 0; ; i++)  // i < Math.Min(nMaxLines, table.Count)
            {
                if (data_reader.Read() == false)
                {
                    if (data_reader.NextResult() == false)
                        break;

                    if (data_reader.Read() == false)
                        break;
                }

                nLineCount++;
#if NO
                if (table.HasRows == false)
                    break;
#endif
                // Line line = table[i];

                if (engine != null)
                {
                    engine.SetGlobalValue("line", data_reader);
                }

                string strLineCssClass = "content";
#if NO
                if (report.OutputLine != null)
                {
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:ReportWriter.cs

示例12: WriteResult

        private static void WriteResult(XmlWriter writer, DbDataReader reader)
        {
            string ns = AdoNetAdapter.MESSAGENAMESPACE;

            writer.WriteStartElement("InboundData", ns);

            do
            {
                writer.WriteStartElement("ResultSet", ns);

                while (reader.Read())
                {
                    writer.WriteStartElement("Row", ns);

                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        if (!reader.IsDBNull(i))
                        {
                            writer.WriteStartElement(reader.GetName(i), ns);

                            object value = reader[i];
                            var serializer = new DataContractSerializer(value.GetType());
                            objectSerializer.WriteObjectContent(writer, value);

                            writer.WriteEndElement();
                        }
                    }

                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            } while (reader.NextResult());

            writer.WriteEndElement();
        }
开发者ID:mi-tettamanti,项目名称:mercury-contrib-adapters,代码行数:36,代码来源:DbHelpers.cs

示例13: ConvertDataReaderToDataSet

        /// <summary>
        /// 由于DataSet得灵活性,提供了一个将DataReader转换为DataSet的工具方法
        /// </summary>
        /// <param name="reader">DbDataReader对象</param>
        /// <returns>DataSet</returns>
        public static DataSet ConvertDataReaderToDataSet(DbDataReader reader)
        {
			ExceptionHelper.TrueThrow<ArgumentNullException>(reader == null, "reader");

            DataSet dataSet = new DataSet();
			dataSet.Locale = System.Globalization.CultureInfo.InvariantCulture;

            do
            {
				DataTable schemaTable = reader.GetSchemaTable();
                DataTable dataTable = new DataTable();

                if (schemaTable != null)
                {
                    // A query returning records was executed
                    for (int i = 0; i < schemaTable.Rows.Count; i++)
                    {
                        DataRow dataRow = schemaTable.Rows[i];
                        // Create a column name that is unique in the data table
                        string columnName = (string)dataRow["ColumnName"]; //+ "<C" + i + "/>";
                        // Add the column definition to the data table
                        DataColumn column = new DataColumn(columnName, (Type)dataRow["DataType"]);
                        dataTable.Columns.Add(column);
                    }
                    dataSet.Tables.Add(dataTable);
                    // Fill the data table we just created
                    //try
                    //{
                        while (reader.Read())
                        {
                            DataRow dataRow = dataTable.NewRow();
                            for (int i = 0; i < reader.FieldCount; i++)
                                dataRow[i] = reader.GetValue(i);
                            dataTable.Rows.Add(dataRow);
                        }
                    //}
                    //catch(Exception exception)
                    //{
                    //    TraceException(exception);
                    //}
                }
                else
                {
                    // No records were returned
                    DataColumn column = new DataColumn("RowsAffected");
                    dataTable.Columns.Add(column);
                    dataSet.Tables.Add(dataTable);
                    DataRow dataRow = dataTable.NewRow();
                    dataRow[0] = reader.RecordsAffected;
                    dataTable.Rows.Add(dataRow);
                }
            }
            while (reader.NextResult());
            return dataSet;
        }
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:60,代码来源:DbTraceHelper.cs


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