代码之家  ›  专栏  ›  技术社区  ›  jan

SqlDataReader仅返回SqlCommand中的第一个选择

  •  4
  • jan  · 技术社区  · 17 年前

    我正在使用 SqlCommand DbCommand

    This this

    PRINT 'We are here'
    SELECT Name FROM Table1
    -- do some logic
    SELECT Name, Country FROM Table1
    PRINT 'We are done'
    

    API'ish语言 .

    2 回复  |  直到 9 年前
        1
  •  9
  •   Matt Howells    17 年前

    Read NextResult 移动到第二次选择的结果。像这样:

    do {
        while (dataReader.Read()) {
            //... process one row
        }
    } while (dataReader.NextResult()) //go to the results of the next SELECT        
    
        2
  •  6
  •   Dave Markle    17 年前
    推荐文章