Skip to content
Advertisement

SqlCommand only returns one row

Trying to only return the first few number of rows because my database was too big, however when I was testing my SQL, I did a select * and was only returned the first row.

What is wrong with my solution?

Advertisement

Answer

In your loop you constantly re-create the instance of the variable logs thus overwriting the previous one and ending with the value of the last record returned by your query. You need a List<Log>

You can use this list as datasource for a grid or just keep it for your future references…

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement