I have written that there is a problem with the function, I realized this problem but the 'fix' only worsened the situation . / D>
This function connects to my DB and does a selected query, then it's The problem is in line: I tried to clear the list, so next time I added a list to my list list, there would be no element in it and all the rows included in the same list. I have to avoid, but instead I PS: Fix I did Thx guys! Instead of list & lt; List & lt; String & gt; & Gt; , returns the desired behavior back to
List & lt; String & gt; for each line and since there are several columns on each line, I can access them with the list list.
try {///} connection connection before reading data. Open (); /// reader = dataCommand.ExecuteReader () Ready to Read; Read the // call before reaching the data (reader.Read ()) {myTestData.Clear (); For (int i = 0; i & lt; howManyColumns; i ++) {/// add myTestData.Add to Maritast data list (reader.GetValue (i) .toString ()); } /// MyTestData add data to DataRao data. Add (Mattextadata); }} Hold (SqlException exSql) {Program.displayExError (exSql, true); }
myTestData.Clear ();
myTestData.Clear (); The list list is wiped out and all of its contents in the list is also lost, to keep data without any idea included in the first list?
myTestData.Clear (); was causing the problem to be added, but if I take it then all the rows are added to the first list and it is not even used. If the problem is not clear please tell me to try and clarify
clear in the current list, you need to create a new list
mydata.Clear () to
myData = new list & lt; String & gt; () .
No comments:
Post a Comment