Discuz!NT
欢迎 游客 , 注册 | 登录 | 会员 | 界面 | 简洁版本 | 在线 | 帮助
商都网教育宝典宝库

发表新主题 回复该主题
本主题被查看1472次, 共1个帖子, 1页, 当前为第1页     选择页数: 1      跳转到第   上一主题   下一主题
标题: Hashtable与DataTable,ArrayList的简单应用(转自cnblogs)
张小峰
超级版主
UID: 14
来自:
精华: 4
积分: 313
帖子: 285
注册: 2007-8-23 10:27:00
状态: 离线
威望: 8.00
金钱: 75.55 元
只看楼主 2007-09-24 08:46
Hashtable与DataTable,ArrayList的简单应用(转自cnblogs)
public void InitData()
2        {
3            string sql = @"select  * from orders";
4
5            SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=sa;database=NorthWind");
6            SqlDataAdapter sda = new SqlDataAdapter(sql, con);
7            DataTable dt = new DataTable();
8            sda.Fill(dt);
9
10            Hashtable htt = new Hashtable(5);
11
12            foreach (DataRow dr in dt.Rows)
13            {
14                htt.Add(dr["orderID"], dr["CustomerID"]);
15
16            }
            ArrayList al = new ArrayList(htt.Values);
            al.Sort();
            for (int i = 0; i < al.Count; i++)
            {
                      //if (al[i].ToString() =="VINET")
                        //{
                            // Response.Write(al[i].ToString());
                          //}
                    Response.Write(al[i].ToString());
            }
19            foreach (DictionaryEntry de in htt)
20            {
21              if (de.Value.ToString == "ALFKI")
22              {
23                  Response.Write(de.Key + "Next .");
24              }
25            }
26            GridView1.DataSource = dt;
27            GridView1.DataBind();
28
29        }
#1  
发表新主题 回复该主题
本主题被查看1472次, 共1个帖子, 1页, 当前为第1页     选择页数: 1      跳转到第







现在的时间是 2008-09-07 08:11:50

版权所有 商都网教育宝典
         Powered by Discuz!NT 1.0.6666    Copyright © 2001-2008 Comsenz Inc.
Processed in 0.032 seconds