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);
}
}
I used the above code to show the database (SQL Server CE 3.5) values in listview but the listview doesn’t show anything! also the message box() shows the database values correctly one by one when loop executes, i think the problem must be in adding values to listview. wat’s wrong with this code, can anyone explain pls?. sorry for my poor english!
thanks in advance,
Ulaga
try with this code
answer with foreach syntax