如何检查数据表是否多于一行 [英] How to Check if DataTable has More Than One Row

查看:66
本文介绍了如何检查数据表是否多于一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个数据表,可能包含一行或多于一行.我想实现一些功能,每检索一行.例如,如果dt.Rows [0]!= null,那么我想填充一些控件.但是当我的数据表返回1行,并且如果dt.Rows [1]!= null时,我检查它是否与第一行相隔第二行.它会引发错误此位置没有行".plz指南.

Hi,
I have a datatable which may contain one row or more than one rows. I want to implement some functionality one each retrived row. For example if dt.Rows[0] != null then i want to populate some controls. But When my datatable returns 1 row and I check whether it has second row apart from first row like this if dt.Rows[1] != null. It throws error " there is not row at this position" plz guide.

推荐答案

为什么不检查计数呢?像(dt.Rows.Count > 1).
Why dont you just check the count? Something like (dt.Rows.Count > 1).


是的..
让人感到不舒服
O yes..
thaks a loooooooooooooooooot


这篇关于如何检查数据表是否多于一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆