使用LINQ的问题 [英] problem in using linq
问题描述
plz帮助...
我需要使用linq从填充的数据集中进行条件搜索,并将其显示在网格中.
这是我的代码
MySqlConnection db = new MySqlConnection(数据库=会员卡;数据源=本地主机;用户ID =根;密码=根");
db.Open();
MySqlDataAdapter da =新的MySqlDataAdapter();
MySqlCommand c = new MySqlCommand(从供应商处选择SupplierId,SupplierCode,CompanyId,SurName",db);
da.SelectCommand = c;
DataSet ds = new DataSet();
da.Fill(ds);
var积=来自ds.Tables [0] .AsEnumerable()中的p,其中p.Field< string>("SupplierCode").ToString()=="12"选择p;
GridView1.DataSource = products.ToList();
GridView1.DataBind();
db.Close();
---------------------------------
我无法从linq查询中获取数据并将其绑定到2个网格...请有人指导我.......
plz help...
I need to make conditional search from a filled data set using linq and need to display it in a grid...
Here s my code
MySqlConnection db = new MySqlConnection("Database=loyaltycard;Data Source=localhost;User Id=root;Password=root");
db.Open();
MySqlDataAdapter da = new MySqlDataAdapter();
MySqlCommand c = new MySqlCommand("select SupplierId,SupplierCode,CompanyId,SurName from supplier", db);
da.SelectCommand = c;
DataSet ds = new DataSet();
da.Fill(ds);
var products = from p in ds.Tables[0].AsEnumerable() where p.Field<string>("SupplierCode").ToString() == "12" select p;
GridView1.DataSource = products.ToList();
GridView1.DataBind();
db.Close();
---------------------------------
I cant get the data from linq query and bind it 2 grid...someone please guide me.......
推荐答案
它可能无法为您提供确切的解决方案.
看看下面的链接" LINQ to DataSet ".
查询数据集– LINQ简介到数据集
下面的链接将为您提供有关" Asp.Net GridView数据绑定"的想法.
http://wiki.asp.net/page.aspx/804/binding-grid -view-control/
编辑-在下面的链接中进行类似的讨论.
http://forums.asp.net/t/1150810.aspx/1
Without looking at your code, its may not be possible to provide you exact solution.
Have a look at below link for "LINQ to DataSet".
Querying DataSets – Introduction to LINQ to DataSet
Below link will provide you idea about "Asp.Net GridView Data Binding".
http://wiki.asp.net/page.aspx/804/binding-grid-view-control/
Edit - Have a look at below link for similar discussion.
http://forums.asp.net/t/1150810.aspx/1
按照链接学习.
http://www.hookedonlinq.com/LINQtoObjects5MinuteOverview.ashx [ http://msdn.microsoft.com/en-us/library/bb907229.aspx [ ^ ]
follow the links learn it.
http://www.hookedonlinq.com/LINQtoObjects5MinuteOverview.ashx[^]
http://msdn.microsoft.com/en-us/library/bb907229.aspx[^]
这篇关于使用LINQ的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!