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


C# SqlCommand.NextResult方法代码示例

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


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

示例1: readFromDataBase

        public void readFromDataBase()
        {
            items.Clear();
            SqlDataReader reader = new SqlCommand(string.Format("SELECT * FROM Items ORDER BY Id;SELECT * FROM Jobs ORDER BY Item;SELECT * FROM Jobs ORDER BY Item;"), cn).ExecuteReader();
            //читаем лист items
            while (reader.Read())
            {
                item newItem = new item();
                newItem.id = reader.GetInt32(0);
                newItem.firstName = reader.GetString(1);
                newItem.lastName = reader.GetString(2);
                items.Add(newItem);
            }

            int i;
            int lastid;

            //читаем лист jobs
            reader.NextResult();
            lastid = i = -1;
            while (reader.Read())
            {
                int k = reader.GetInt32(4);
                if (lastid != k)
                {
                    do ++i;
                    while (k != items[i].id);
                    lastid = reader.GetInt32(4);
                }
                items[i].jobs.Add(new job(reader.GetDateTime(0), reader.GetString(1), reader.GetString(2), reader.GetString(3)));
            }

            //читаем лист positions
            reader.NextResult();
            lastid = i = -1;
            while (reader.Read())
            {
                if (lastid != reader.GetInt32(4))
                {
                    do i++;
                    while (reader.GetInt32(4) != items[i].id);
                    lastid = reader.GetInt32(4);
                }
                items[i].positions.Add(new position(reader.GetInt64(0),reader.GetInt64(1),reader.GetInt32(2),reader.GetDateTime(3)));
            }
            reader.Close();
        }
开发者ID:ASIXz,项目名称:SecondTask,代码行数:47,代码来源:Program.cs

示例2: GetLinkedDatabaseList

 public List<LinkedDatabase> GetLinkedDatabaseList()
 {
     if (!this.IsSqlServer)
     {
         throw new NotSupportedException("This operation is supported only for SQL Server.");
     }
     StringBuilder builder = new StringBuilder();
     List<string> list = new List<string>();
     List<LinkedDatabase> list2 = new List<LinkedDatabase>();
     string cmdText = "select data_source from sys.servers where provider = 'SQLNCLI' and is_linked = 1";
     using (SqlConnection connection = new SqlConnection(this.GetCxString()))
     {
         SqlDataReader reader;
         connection.Open();
         using (reader = new SqlCommand(cmdText, connection).ExecuteReader())
         {
             while (reader.Read())
             {
                 string item = reader[0].ToString();
                 list.Add(item);
                 builder.AppendLine("select name from [" + item + "].[master].[sys].[databases]");
             }
         }
         int num = 0;
         using (reader = new SqlCommand(builder.ToString(), connection).ExecuteReader())
         {
             while (reader.Read())
             {
                 list2.Add(new LinkedDatabase(list[num], reader[0].ToString()));
                 continue;
             Label_00D6:
                 if (!reader.NextResult())
                 {
                     return list2;
                 }
                 num++;
             }
             goto Label_00D6;
         }
     }
 }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:41,代码来源:Repository.cs


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