I
Islam Elkhayat
I need help plzzzz... In my windows application i fill listview from simple
access database...
here is the code
//Creating colums
InitializeComponent();
listView_result.Columns.Add("ID",87,HorizontalAlignment.Left);
listView_result.Columns.Add("Name",180,HorizontalAlignment.Left);
listView_result.Columns.Add("Cash",81,HorizontalAlignment.Left);
//Fill the listview
try
{
oleDBConn.open();
SelectCommand.CommandText = "SELECT Serial_no, Name, Cash from Cheque";
OleDbDataReader reader;
reader = SelectCommand.ExecuteReader();
listView_result.Clear();
while(reader.Read())
{
ListViewItem lvi= new ListViewItem(reader["Serial_no"].ToString());
lvi.SubItems.Add(reader["Name"].ToString());
lvi.SubItems.Add(reader["Cash"].ToString());
listView_result.Items.Add(lvi);
}
reader.Close();
oleDBConn.close();
} catch (Exception e) { MessageBox.Show(e.ToString()); }
When i click the fill button the column disappear and the control look like
it's freeze!!!
there is no problem in the connection string or the query, the while loop is
working but when it come to dispaly result the problem rise.
What's wrong... i need urgent help
access database...
here is the code
//Creating colums
InitializeComponent();
listView_result.Columns.Add("ID",87,HorizontalAlignment.Left);
listView_result.Columns.Add("Name",180,HorizontalAlignment.Left);
listView_result.Columns.Add("Cash",81,HorizontalAlignment.Left);
//Fill the listview
try
{
oleDBConn.open();
SelectCommand.CommandText = "SELECT Serial_no, Name, Cash from Cheque";
OleDbDataReader reader;
reader = SelectCommand.ExecuteReader();
listView_result.Clear();
while(reader.Read())
{
ListViewItem lvi= new ListViewItem(reader["Serial_no"].ToString());
lvi.SubItems.Add(reader["Name"].ToString());
lvi.SubItems.Add(reader["Cash"].ToString());
listView_result.Items.Add(lvi);
}
reader.Close();
oleDBConn.close();
} catch (Exception e) { MessageBox.Show(e.ToString()); }
When i click the fill button the column disappear and the control look like
it's freeze!!!
there is no problem in the connection string or the query, the while loop is
working but when it come to dispaly result the problem rise.
What's wrong... i need urgent help