Usually you pass a DataTable or a DataSet as value for the DataSource property
DataTable dt = new DataTable();
dt.Load(reader);
tableListhist.DataSource = dt;
Question
I try read data from oracle db and set data to datagridview component but I dont know where is the problem datagridview is empty, if I test reader throught while loop and get values I see all rows:
CODE:
Dbc dbc = new Dbc();
dbc.connect();
try
{
String sql = "SELECT * FROM " + _tname;
OracleCommand comm = new OracleCommand(sql, dbc.getConnection());
OracleDataReader reader = comm.ExecuteReader();
tableListhist.ColumnCount = reader.FieldCount;
for (int i = 0; i < reader.FieldCount; ++i)
{
tableListhist.Columns[i].HeaderText = reader.GetName(i).ToLower();
}
//tableListhist.DataMember = _tname;
tableListhist.DataSource = reader;
reader.Close();
tableListhist.ReadOnly = true;
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
finally
{
dbc.close();
}
But datagridview is empty :(
La solution
Usually you pass a DataTable or a DataSet as value for the DataSource property
DataTable dt = new DataTable();
dt.Load(reader);
tableListhist.DataSource = dt;