Pass OledbConnection in between forms
Posted on 2004-10-28
I need to know how to pass a connection (or datareader etc.) between forms in vb.net.
I have 2 forms, on the first one the user drags text from a datagrid and drops it into a listbox. On the drop I open a connection and search for results from a database. If there is only 1 result then the result gets added to the listbox, however, if there is more than one result i want to open another form displaying the results for the user to select from.
I'd prefer to use the same connection I've already opened on the first form on the second form as well rather than opening another connection.
Is there any way to do this other than declaring a public connection in a module?
Alternatively, can I do the search on the first form to a datareader or dataset and then pass this to the second form?