access the connection from other form

  • Thread starter Daniel Sélen Secches
  • Start date
D

Daniel Sélen Secches

I have a connection on form1 of my project.

who can i use it from another form displayed as showdialog?

i've just tried do that...

formMain has the connection named as conn

from form2

Private Sub form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
formMain.conn.open()
....
end sub

but i've got a error.

thanks for any help.
 
A

Armin Zingler

Daniel Sélen Secches said:
I have a connection on form1 of my project.

who can i use it from another form displayed as showdialog?

i've just tried do that...

formMain has the connection named as conn

from form2

Private Sub form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
formMain.conn.open()
...
end sub

but i've got a error.

Whenever you want to access an object, you need a reference. If you don't
have a reference you have to make it available. This is usually done by a
public property or as an argument of a public procedure.
 
H

Herfried K. Wagner [MVP]

* "Daniel Sélen Secches said:
I have a connection on form1 of my project.

who can i use it from another form displayed as showdialog?

i've just tried do that...

formMain has the connection named as conn

from form2

Private Sub form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
formMain.conn.open()

Use 'DirectCast(Me.Owner, MainForm).conn.Open()'.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top