ExecuteReader is returning only 1 value?

Your reader is returning all the values but the code.

Your reader is returning all the values but the code - returnvalue = test. GetString(0); will keep overwriting the returnvalue variable with the next value returned from the datareader so you will only be left with the last value. You could create a list of strings - List list = new List(); then add each value returned to the list - while (test.Read()) { list.

Add(test. GetString(0)); } then return the list from your function instead of a string.

1. Nice explanation of both the problem and the solution. – Ken White Nov 12 at 19:04 Thanks.

Very nice explanation. I returned the list using returnValue = string. Join("\n", list.ToArray()); return returnValue; – Rupert Nov 15 at 14:27.

Using the data reader you pick up one question name only and override its value on each read - then you return that last item. Instead just use a List to hold all your values and return that: List questionNames = new List(); while (test.Read()) { questionNames. Add(GetString(0)); }.

You are right - I fixed that first sentence. – BrokenGlass Nov 12 at 19:01 +1. Nice sample code for the fix.

– Ken White Nov 12 at 19:03.

While (test.Read()) { returnvalue = test. GetString(0); } There's your problem. You're looping that multiple times, each time overwriting it with the last value, then returning once.

You want a list and .add() instead.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions