Jeppe Christensen Jeppe Christensen - 10 days ago 5
MySQL Question

Reader doesn't return all rows from database

So i have a web api that presents values from my database. However i have 6 rows in my database, but it doesn't return the first row.

How do i get it to read and return all rows in my database?

cmd.CommandText = "SELECT * FROM `CustomerDb`";
cmd.CommandType = CommandType.Text;
cmd.Connection = mySqlConnection;

MySqlDataReader reader = cmd.ExecuteReader();

var listOfPlace = new List<Place>();

if (reader.Read())
while (reader.Read())
var Place = new Place();
Place.ID = Convert.ToInt32(reader["id"]);
Place.Name = reader["name"].ToString();
Place.Address = reader["address"].ToString();
Place.City = reader["city"].ToString();
Place.Category = reader["category"].ToString();

return listOfPlace;


Remove if block.

if (reader.Read())