【发布时间】:2020-05-18 11:05:19
【问题描述】:
我的 SQL db 存储过程返回结果,但 datareader 显示“Enumeration Yielded No Results”?
这是我的代码:
var sqlFastProd = String.Format("Getnpidataforencryption");
using (SqlConnection conn = new SqlConnection(connectionString.ToString()))
{
SqlCommand myCommand = new SqlCommand(sqlFastProd, conn);
myCommand.CommandType = System.Data.CommandType.StoredProcedure;
myCommand.Parameters.Add(new SqlParameter("@StartingId", startId));
myCommand.Parameters.Add(new SqlParameter("@countOfRecords", CountofRecords));
conn.Open();
SqlDataReader reader = myCommand.ExecuteReader();
List<DataElement> dataElements = new List<DataElement>();
var recordsFetchTime = DateTime.Now;
TimeSpan t = serviceStartTime - recordsFetchTime;
if (reader.HasRows)
{
while (reader.Read())
{
…
}
}
}
存储过程
创建过程Getnpida
taforencryption @StartingId BIGINT,--1
@countOfRecords BIGINT -- 101
AS
BEGIN
SELECT textid,
originaltextdata as textdata,
keyname
FROM npidataencryption
WHERE IsEncrypted is null and id BETWEEN @StartingId AND @countOfRecords
END
need help, thanks in adv
ance:)
【问题讨论】:
标签: c# ado.net sqldatareader datareader