Click here to Skip to main content
15,749,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to VB.Net. I have a backgroundworker routine that shares OleDBConnection with UI. Note when backgroundworker uses OleDBConnection, it's not used by UI routines. The strange thing is when I run the program in design environment (visual basic express 2010), it works fine. But when I run the executable in other computers, it stops at OleDb.OleDbDataReader line. I use and .close statement throughout the program - again it works in the design environment. Has anyone seen this? What do I need to do?

1 solution

Don't "share" a single connection object through out your code.

Create a new object when you need it, use it, dispose it when you done with the query. There is no advantage to "sharing" a single connection object throughout your code.
Share this answer
Member 8475769 28-Apr-13 17:58pm    
Thank you for your quick reply. I tried to dispose reader as well as the connection every time I used the query, but still the same happens - it works when I run it through Visual Basic 2010, but it doesn't work when I run it as an executable in other computers. This happens only for the backgroundworker routine. UI routines that use queries are fine.
Dave Kreskowiak 28-Apr-13 21:01pm    
Well, without seeing the code that's failing, it's pretty much impossible to say whats wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900