Baba mba Baba mba - 3 months ago 31
C# Question

Why do i get System.Data.DataRow?

I wanna show my rows in a listbox and the table names but when i run my code it says System.Data.DataRow can someone help me

my code is

foreach (object SelectedValue in ListEmployees.SelectedItems)
using (connection = new SqlConnection(connectionstring))
using (SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM " + selectedCel, connection))
DataTable employees = new DataTable();

for (int i = 0; i < employees.Rows.Count; i++)
DataRow dr = employees.Rows[i];
ListViewItem itm = ListViewItem(dr.ToString());



DataRow.ToString() just prints out the full type name.

Presuming you want to show the first column:

ListViewItem itm = new ListViewItem(dr.Field<string>(0));