当前位置:编程学习 > C#/ASP.NET >>

急急急急急急急急急急急急!ListView要绑定Access数据库并显示里面的东西

请问各位大仙如何对ListView绑定Access数据库,并且显示里面的两栏内容!!!!!!!!!谢谢谢谢 listview access 数据库 --------------------编程问答-------------------- 1.读取ACCESS
  OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source = " + _Global.ConnectStrOfAccess + "test.mdb");
            conn.Open();
            string sqlString = "select * from t ";
            OleDbCommand oleDbCommand1 = new OleDbCommand(sqlString, conn);          

            oleDbCommand1.CommandText = sqlString;
            OleDbDataReader reader = oleDbCommand1.ExecuteReader();//执行查询
            if (reader.Read())
            {
               
            }
            else
            {

               
            }
--------------------编程问答-------------------- 2.绑定listview 
DataTable dt= getdt();

            this.LVData.Columns.Add("aaa", 70, HorizontalAlignment.Left);
            this.LVData.Columns.Add("bbb",100, HorizontalAlignment.Left);
            this.LVData.Columns.Add("ccc", 100, HorizontalAlignment.Left);
            this.LVData.Columns.Add("ddd", 140, HorizontalAlignment.Left);
    
            LVData.View = View.Details;


            string[] str = new string[4];
            if (dt.Rows.Count != 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    str[0] = dr["autoID"].ToString();
                    str[1] = dr["PName"].ToString();
                    str[2] = dr["PEName"].ToString();
                    str[3] = dr["PComment"].ToString();
                 
                    ListViewItem item = new ListViewItem(str, 0);
                    LVData.Items.Add(item);
                }
            } --------------------编程问答-------------------- ListView绑定不了数据   只能添加
查询出数据后  一个单元格一个单元格的添加
或是 New ListViewItem(string[] value)
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,