|
|||||||
Index was outside the bounds of the array using SQLITE
Время создания: 17.01.2020 06:28
Автор: https://stackoverflow.com/questions/39179376/index-was-outside-the-bounds-of-the-array-using-sqlite-and-c-sharp
Текстовые метки: Index was outside the bounds of the array using SQLITE, ошибки sqlite
Раздел: Компьютер - C# - SQLite - Ошибки
Запись: Kozlov-AE/Tetra/master/base/1579231718zcper49jvw/text.html на raw.githubusercontent.com
|
|||||||
|
|||||||
A possible reason is because the row id is not zero based or there are jumps due to deleted rows and similar things, hence it can't be used as array row index. Replacing foreach with a for could be an idea to fix it. Furthermore you're dimensioning the matrix with the id of the last row, that is not guaranteed to be the max id. And even if it is and it is zero based, you need to add one to get the correct row dimension. string[,] data = new string[d1+1, d2]; But a Count instead of Last would be more reasonable in the first place. answered Aug 27 '16 at 9:48 user6996876 when rows got deleted, doesnt the next rows fill up the blank and get shifted up automatically? and isn't the first row always start on an index of 0? – Infinity loop of probs Aug 27 '16 at 9:55 When a row is deleted the id of the following one does not change – user6996876 Aug 27 '16 at 9:59 so how do you move it to fill the blank? – Infinity loop of probs Aug 27 '16 at 10:19 Back to the exception. You're dimensioning the matrix with the I'd of the last row and also this is not guaranteed to be the max id. – user6996876 Aug 27 '16 at 11:18 Finally, if you have N rows the last one will likely have id N-1 and that is not the correct dimension (N) to instanciate the matrix – user6996876 Aug 27 '16 at 11:36 |
|||||||
|
|||||||
|