Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.ObjectDisposedException: 'Cannot access a disposed object. Object name: 'SQLiteConnection'.' #5

Open
dchubad opened this issue Aug 12, 2021 · 0 comments

Comments

@dchubad
Copy link

dchubad commented Aug 12, 2021

I created a simple form with a button, when clicked will run a function called populate(). using the chunk of code below causes an error as in the title of this post.

        private void Populate()
        {
            var countStatementBuilder = new CountStatementBuilder();
            countStatementBuilder.CommandText("SELECT COUNT(*) FROM dbMyBirds");

            var rowsStatementBuilder = new RowsStatementBuilder();
            rowsStatementBuilder.CommandText("SELECT * FROM dbMyBirds LIMIT {1} OFFSET {2}");

            dataGridViewPaging1.DbRequestHandler = new DbRequestHandler
            {
                Connection = new SQLiteConnection("Data Source=dbMyBirds.sqlite3"),
                CountStatementBuilder = countStatementBuilder,
                RowsStatementBuilder = rowsStatementBuilder
            };
        }

The first time I click the button it will populate the datagridview, the 2nd time I get an Exception Unhandled
System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'SQLiteConnection'.'

The only changes I made was pointing it to my db file and db name.

Edit:
I was hoping to be able to implement some search features such as searching by various columns, keywords, return limited search results... thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant