数据集过滤器中的条件 [英] Condition in dataset filter
问题描述
这是我的代码,
Conn.Open();
DataTable dt = new DataTable();
DataSet ds = new DataSet();
SqlCommand sqlCmd = new SqlCommand( SELECT * from CurrentDataCR,Conn);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(ds);
ds.Tables [0] .DefaultView.RowFilter =mst_remote_station_id赞'* 9001 *';
这里我得到id为9001的完整行。我只需要一个列值就可以了。
我尝试过:
请建议我解决方案
Here is my code,
Conn.Open();
DataTable dt = new DataTable();
DataSet ds = new DataSet();
SqlCommand sqlCmd = new SqlCommand("SELECT * from CurrentDataCR ",Conn);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(ds);
ds.Tables[0].DefaultView.RowFilter = " mst_remote_station_id Like'*9001*'";
Here I am getting Complete row for id 9001. I need only one column value for this id.
What I have tried:
Please Suggest me the solution
推荐答案
然后写quer喜欢这个
then write query like this
SqlCommand sqlCmd = new SqlCommand("SELECT id from CurrentDataCR ",Conn);
而不是选择(即检索)所有列
instead of selecting (i.e retrieving ) all column
这篇关于数据集过滤器中的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!