string query = \"select * from cfo_daily_trans_hist\"; try { using (SqlConnection connection = new SqlConnection(
Instead of a SqlDataReader, use a SqlDataAdapter.
SqlDataReader
SqlDataAdapter
SqlDataAdapter myAdapter = new SqlDataAdapter(command); myAdapter.Fill(datatable);
With a SqlDataAdapter, you don't need to explicitly call SqlConnection.Open() and SqlConnection.Close(). It is handled in the Fill() method.
SqlConnection.Open()
SqlConnection.Close()
Fill()