Sqlite-net newbie, always Index was out of range ?

hi, Im new using sqllite-net, always got error Index was out of range, something is not clean ?

here my example:

            string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "TestDB");
            SQLiteConnection dbTest = new SQLiteConnection(dbPath);
            dbTest.CreateTable<TestTable>();

            dbTest.Insert(new TestTable() { TestField = @"ABC\123", }); //<--**ALWAYS ERROR HERE ON SECOND RUN**

Step :
1. Run F5 for firstime is ok
2. Close the apps
3. Run F5 Second time got error :

Unhandled Exception:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Any help will be appreciated
TIA
Sen

Best Answer

  • hng78hng78 ID ✭✭
    Accepted Answer

    I have found the culprit

    somehow the page where error occurs was call from

    Task.Run (async ()=> await GlobalNav.PushAsync(new TestPage))
    

    I change the procedure into Async

    await GlobalNav.PushAsync(new TestPage)

    the error do not occurs anymore

Answers

  • JiriMatejkaJiriMatejka CZMember ✭✭✭

    Can you post the TestTable class code?

  • hng78hng78 IDMember ✭✭
        public class TestTable
        {
            public string TestField { get; set; }
        }
    

    nothing special i guest

  • hng78hng78 IDMember ✭✭
    Accepted Answer

    I have found the culprit

    somehow the page where error occurs was call from

    Task.Run (async ()=> await GlobalNav.PushAsync(new TestPage))
    

    I change the procedure into Async

    await GlobalNav.PushAsync(new TestPage)

    the error do not occurs anymore

Sign In or Register to comment.