Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Pass OledbConnection in between forms

Posted on 2004-10-28
2
Medium Priority
?
234 Views
Last Modified: 2010-04-24
Hello all,

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?


Thanks
Charel

0
Comment
Question by:cpk68
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 1000 total points
ID: 12432374
If lets say that form2 has a datagrid you want to fill with the results from the first form you can do something like this

FORM1.

^Pseudo Code
dim ds as new dataset
'your search
if ds.rows.count > 1 then
  dim f as new form2
  f.datagrid1.datasource = ds.tables(0)
  f.show
elseif ds.rows.count = 1 then
  'add to listbox
else
  'no rows found
endif
0
 

Author Comment

by:cpk68
ID: 12432456
Thank you kindly. Almost too simple :o)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question