- http://www.google.co.th/search?q=how+to+query+in+datatable&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
- http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/26b1f5f2-fb6f-4965-b20c-3d20a222d06c
- http://www.xtremedotnettalk.com/showthread.php?t=101538
- http://www.greatfriends.biz/webboards/msg.asp?id=5637
- http://bytes.com/groups/net-asp/334188-how-sql-query-cached-datatable
- http://www.queryadataset.com/
Here's a simple C# example:
DataSet ds = new DataSet();
//populate from commercial database or read offline XML file
string sql = "SELECT TRIM(name), COUNT(name) As 'Total' FROM table1 GROUP BY name ORDER BY 1";
DataView dv = QueryADataSet.DsCommand.Execute(sql, ds);
GridView1.DataSource = dv;
GridView1.DataBind();
Native assemblies for .NET 1.1 and .NET 2.0/3.0.
--------------------------------
//LINQ Example
DataRow row = customers.AsEnumerable()
.Where(i => i.Field
.FirstOrDefault();
//LINQ - Strongly Typed DataSet
DataRow row = ds.Customers.AsEnumerable()
.Where(i => i.CustID == 4)
.FirstOrDefault();
//DataTable Example
DataRow row = customers.Select("CustID = 4")[0];
//DataView Example
DataView dv = new DataView(customers);
dv.RowFilter = "CustID = 4";
--------------------------------
DataView dv = new DataView(MyDataset.Tables["TableName"], "Column1 = " + TestNumtextBox.Text + "and Column2 Like '%" + VehNumtextBox.Text+ "%'","", DataViewRowState.CurrentRows);
you can iterate through the rows in dataview like this
foreach (DataRowView drv in dv)
{
value = (int)drv["column1"];
}
--------------------------------
No comments:
Post a Comment