问题描述
我在VS中查询了一个表,结果得到了两行。 将select查询复制到字符串查询中,然后用params替换搜索值,如下所示
string selectQuery =" select * from Table其中ColumnX = @ Value1和ColumnY = @ Value2" ;;
SqlCommand Query = new SqlCommand(selectQuery,Connection);Query.Parameters.AddWithValue(" @ Value1",object.GetValue1());
Query.Parameters.AddWithValue(" @ Value2",object.GetValue2());
执行期间正在使用正确的getter值,但执行后
SqlDataReader reader = Query.ExecuteReader();
读者HasRows为true,ViewResults为空。 枚举没有产生任何结果。 查询如何返回行但没有结果? 逻辑上来说,如果ViewResult为空,则HasRows应为false。 可能导致这种情况的原因是什么?
I queried a table in VS and got two rows as result. Copied the select query into string query, then replaced search values with params as below
string selectQuery = "select * from Table where ColumnX = @Value1 and ColumnY= @Value2";
SqlCommand Query = new SqlCommand(selectQuery, Connection);Query.Parameters.AddWithValue("@Value1", object.GetValue1()); Query.Parameters.AddWithValue("@Value2", object.GetValue2());
During execution the correct getter values are being used, yet after executing
SqlDataReader reader = Query.ExecuteReader();
reader HasRows is true, ViewResults empty. Enumeration yielded no results. How can a query return rows but no results? Logically to me, if ViewResult is empty, HasRows should be false. What could be causing this?
这篇关于SQLReader HasRows = true,ResultsView为空,Enumeration没有产生任何结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!