private void table_loader()
{
SqlCeConnection ucon = new SqlCeConnection();
ucon.ConnectionString = " Data Source=C:\\Documents and Settings\\laser\\My Documents\\Visual Studio 2008\\Projects\\dbtest\\dbtest\\ulist.sdf";
ucon.Open();
SqlCeCommand uce = new SqlCeCommand();
SqlCeDataAdapter uced = new SqlCeDataAdapter();
uced.SelectCommand = new SqlCeCommand("SELECT * FROM plist", ucon);
uced.Fill(ulistDataSet, "plist");
DataTable dplist = ulistDataSet.Tables["plist"];
for (int i = 0; i <dplist.Rows.Count;i++)
{
DataRow drow = dplist.Rows[i];
ListViewItem lvi = new ListViewItem(drow["Process"].ToString());
MessageBox.Show(lvi.Text);
listView2.Items.Add(lvi);
}
}
我使用上面的代码在列表视图中显示数据库(SQL Server CE 3.5)值,但列表视图没有显示任何内容!当循环执行时,消息框()也会一一正确显示数据库值,我认为问题一定出在将值添加到列表视图中。这段代码有什么问题,有人可以解释一下吗?对不起我糟糕的英语!
在此先感谢, 乌拉加