我的数据表不会返回任何行 [英] My datatable does not return any row

查看:80
本文介绍了我的数据表不会返回任何行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用数据适配器填充方法填充DataTable,但数据表对象不返回任何行。

I am trying to fill DataTable using data adapter fill method , but data table object does not return any row.

Sqlconnection conn=new sqlconnectiön(Select* from register, conn);           
conn.open( );  
SqlDataAdapter DA = new SqlDataAdapter(Select*from register,conn );
DataTable dt = new DataTable( );   
DA.Fill(dt); //now i am trying to check is dt return any row . 
If(dt.rows.count> 0) 
{
   //then some code
}



我的问题出现在这里..因为datatable对象dt不返回任何行? Plz帮助...只有收件箱me ..并且不建议使用数据集。


my problem arise here..because datatable object dt does not return any row ? Plz help... Only inbox me..and do not suggest to use dataset.

推荐答案

您正在创建一个新的DataAdapter和一个新的DataTable但从未将它与你的联系。这是官方文档, http://msdn.microsoft.com/en- us / library / system.data.sqlclient.sqldataadapter.aspx [ ^ ],或只是谷歌的例子。有很多。
You are creating a new DataAdapter and a new DataTable but never associating it with your connection. Here is the official documentation, http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.aspx[^], or just google for examples. There's tons of them.


这篇关于我的数据表不会返回任何行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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