Vb.NET Threads and global variables
Posted on 2007-11-28
I have a globally defined variable (interface?) to my database in ApplicationEvents.vb. (public DB as TransDB)
On startup (MyApplication_Startup) it creates a new instance of the interface, and connects to the database.
then, in the rest of my program i can read/write by using
This works through all my code, except inside a thread.
The thread is for printing and what it does is
1) show a form to allow the user to select the documents to be printed
2) extracts an embedded excel file
3) starts excel and maps data from either a) a form the user has modified, or b) from a saved entry in the database
4) prints the specified documents
inside the thread My.Application.DB is 'Nothing' and the program crashes.
How can I access this so I don't have to create a 2nd connection?