加载数据提示Min(5) must be less than or equal to max(-1) in Range object

User通过Excel导入200多条数据到系统中,查看时提示“Min(5) must be less than or equal to max(-1) in Range object”错误。

调试发现在执行代码“DataRow[] rows = evasups.Select(string.Format("MatID={0} and SupCode='{1}'", matid, sups[i]));”时,直接报以上错误。

百度了一下,网上有说是因为数据库字段为字符串,但条件中没有加单引号造成的。

但此处MatID字段在数据库中是int型的,后尝试添加单引号竟然可以了,这说明在Select()方法中添加条件最好加上单引号(不管是否为int型)

原文地址:https://www.cnblogs.com/jxw-29/p/8288396.html