I’ve got a winform with some child forms on it. Now I’m accessing the child forms by a treeview in my main form. Now in that treeview is a list of websites. Since a website is actually a group of pages, this is also shown in the tree. Website is my parent and the pages are the childs.
When you click on one of the pages the statistics are shown in a child form. When clicked on a website a summary of all pages is shown of that website. Since this can have a lot of data I’m using a background worker that fetches the statics in the background after the treeview is loaded.
Now all fine until I’m changing something in the statistics and it saves automatically into the database (sqlserver2008). Then my backgroundworker generates errors saying the sqlreader is closed. So I’m wondering how I can solve this.
Do I have to access the database on a separate connection? Any other ideas?
Thanks
Are you using the same database connection object on several threads? That’s not safe. Every thread must have its own database connection, or it must synchronize the usage so that only one thread accesses the database connection object at any given moment.