User-939850651 posted
Hi mansooraabid,
According to your description, I tried but could not reproduce your problem.
What are the results you expect from the query? As written in your code, the DataTable is empty means that the SqlDataReader is empty.
You could use the debugging tool to check whether the result you expect exists in the SqlDataReader object.
string conStr = ConfigurationManager.ConnectionStrings["conStr"].ToString();
string query = "select * from tableTest";
using (SqlConnection conn = new SqlConnection(conStr))
{
conn.Open();
SqlTransaction transaction = conn.BeginTransaction();
using (SqlCommand cmd = new SqlCommand(query, conn, transaction))
{
using (SqlDataReader reader = cmd.ExecuteReader())
{
DataTable MyTable = new DataTable();
MyTable.Load(reader);
//
Console.WriteLine("");
}
}
}
Result:

I recommend that you could use SqlDataAdapter to fill the data table, like this:
using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) {
DataTable MyTable = new DataTable();
sda.Fill(MyTable);
}
Hope this can help you.
Best regards,
Xudong Peng