导读:
2007-04-29 作者:bitsCN整理 来源:中国网管联盟 PV:286
关键词:
显示结果
CustomerID CompanyName Country
WHITC White Clover Markets USA
TRAIH Trail's Head Gourmet Provisioners USA
THECR The Cracker Box USA
THEBI The Big Cheese USA
SPLIR Split Rail Beer &Ale USA
SAVEA Save-a-lot Markets USA
RATTC Rattlesnake Canyon Grocery USA
OLDWO Old World Delicatessen USA
LONEP Lonesome Pine Restaurant USA
LETSS Let's Stop N Shop USA
LAZYK Lazy K Kountry Store USA
HUNGC Hungry Coyote Import Store USA
GREAL Great Lakes Food Market USA
[bitsCN_com]
源代码
bitsCN~com<% @Import Namespace="System.Data" %><% @Import Namespace="System.Data.SqlClient" %>bbs.bitsCN.com使用DataTable进行检索和排序示例 <script language="C#" runat="server">bitsCN#com中国网管联盟
void Page_Load(object sender, System.EventArgs e)
{ bitsCN#com中国网管联盟
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionSqlServer"];
string Sql = "SELECT CustomerID, CompanyName, Country FROM Customers"bbs.bitsCN.com中国网管论坛
SqlConnection thisConnection = new SqlConnection(ConnectionString);
SqlDataAdapter adapter = new SqlDataAdapter(Sql, thisConnection);
// 创建DataTable对象www_bitscn_com中国.网管联盟 DataTable table = new DataTable();
// 填充数据到DataTable adapter.Fill(table); [bitsCN.Com]
// 定义筛选条件字符串和排序字符串 string strExpr = "Country = 'USA'" string strSort = "CompanyName DESC"[bitsCN_com]
// 获得经过筛选和排序后的数据 DataRow [] resultRows = table.Select(strExpr, strSort);
// 显示经过筛选和排序后的数据[bitsCN_com] DisplayRows(resultRows, DisplayLabel);
}
// 显示DataRow数组中的内容 public void DisplayRows(DataRow [] rows, Label label) 中国_网管联盟bitsCN.com
{
// 检查返回数据是否为空中国_网管联盟bitsCN.com if(rows.Length <= 0)
{
BBS.bitsCN.com网管论坛
label.Text = "没有数据" return } label.Text = ""[bitsCN.Com]
// 遍历DataRow数组的行和列,显示数据 label.Text += "
BBS.bitsCN.com网管论坛
{
label.Text += "
label.Text += row[i];
label.Text += "" }bitsCN#com中国网管联盟
label.Text += "
?> foreach(DataRow row in rows) { bitsCN.nET*中国网管博客 label.Text += "
" for(int i=0 i
" } label.Text += "
"www_bitscn_com中国.网管联盟
} </script> DL@bitsCN_com网管软件下载
DL@bitsCN_com网管软件下载
相关文章:
如何对DataTable进行检索和排序 评论:
评论加载中…
责任编辑:网盟 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。
本文转自
http://www.bitscn.com/dotnet/ado/200709/109670.html
2007-04-29 作者:bitsCN整理 来源:中国网管联盟 PV:286
关键词:
显示结果
CustomerID CompanyName Country
WHITC White Clover Markets USA
TRAIH Trail's Head Gourmet Provisioners USA
THECR The Cracker Box USA
THEBI The Big Cheese USA
SPLIR Split Rail Beer &Ale USA
SAVEA Save-a-lot Markets USA
RATTC Rattlesnake Canyon Grocery USA
OLDWO Old World Delicatessen USA
LONEP Lonesome Pine Restaurant USA
LETSS Let's Stop N Shop USA
LAZYK Lazy K Kountry Store USA
HUNGC Hungry Coyote Import Store USA
GREAL Great Lakes Food Market USA
[bitsCN_com]
源代码
bitsCN~com<% @Import Namespace="System.Data" %><% @Import Namespace="System.Data.SqlClient" %>bbs.bitsCN.com
void Page_Load(object sender, System.EventArgs e)
{ bitsCN#com中国网管联盟
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionSqlServer"];
string Sql = "SELECT CustomerID, CompanyName, Country FROM Customers"bbs.bitsCN.com中国网管论坛
SqlConnection thisConnection = new SqlConnection(ConnectionString);
SqlDataAdapter adapter = new SqlDataAdapter(Sql, thisConnection);
// 创建DataTable对象www_bitscn_com中国.网管联盟 DataTable table = new DataTable();
// 填充数据到DataTable adapter.Fill(table); [bitsCN.Com]
// 定义筛选条件字符串和排序字符串 string strExpr = "Country = 'USA'" string strSort = "CompanyName DESC"[bitsCN_com]
// 获得经过筛选和排序后的数据 DataRow [] resultRows = table.Select(strExpr, strSort);
// 显示经过筛选和排序后的数据[bitsCN_com] DisplayRows(resultRows, DisplayLabel);
}
// 显示DataRow数组中的内容 public void DisplayRows(DataRow [] rows, Label label) 中国_网管联盟bitsCN.com
{
// 检查返回数据是否为空中国_网管联盟bitsCN.com if(rows.Length <= 0)
{
BBS.bitsCN.com网管论坛
label.Text = "没有数据" return } label.Text = ""[bitsCN.Com]
// 遍历DataRow数组的行和列,显示数据 label.Text += "
BBS.bitsCN.com网管论坛
{
label.Text += "
label.Text += row[i];
label.Text += "" }bitsCN#com中国网管联盟
label.Text += "
} </script> DL@bitsCN_com网管软件下载
DL@bitsCN_com网管软件下载
相关文章:
如何对DataTable进行检索和排序 评论:
评论加载中…
责任编辑:网盟 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。
本文转自
http://www.bitscn.com/dotnet/ado/200709/109670.html