Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / July 2003



Tip: Looking for answers? Try searching our database.

Child forms need access

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Aaron Todd - 30 Jul 2003 21:46 GMT
I am trying to create a MDI program in VB.NET 2003.  My problem is that I
have declared all my ado connection information on the main form.  It works
great and I am able to manupulate the data.  But how do I give my child
forms access to the dataset and connection and stuff?

Thanks,

Aaron
Simeon Nevel - 30 Jul 2003 22:10 GMT
"Aaron Todd" <atodd109@hotmail.com> wrote in message:
> I am trying to create a MDI program in VB.NET 2003.  My problem is that I
> have declared all my ado connection information on the main form.  It works
> great and I am able to manupulate the data.  But how do I give my child
> forms access to the dataset and connection and stuff?

Well....

This a a VB classic newsgroup.  For a .Net specific answer go to a newsgroup
with .dotnet in it's name.

But, assuming the .NET works (in these areas) the same way as VB Classic
(not
always a safe assumption) you can try anyone of the following:

1)  Declare all your connection/recordset/command/etc. objects as public in
    a .BAS module.

2) Declare connection/recorset/command objects as needed as Public variables
at
   the module level in the MDI forms and do something like:

   Set frmMDI.pubRS = currRS

3) Declare connection/recordset/command objects as needed as Private
variables
   at the module level in the MDI forms and code Property Let/Get/Set
procedures in the MDI

I chose the 3rd option in my VB class final project, like so:

In the MDI form:

     Dim m_conn As ADODB.Connection

     Public Property Set Connection(ByVal Connection As ADODB.Connection)
         Set m_conn = Connection
     End Property

In the MDI parent:

      Dim frm As frmMDI
      Dim conn as ADODB.Connection

     ' Do whatever you need to do to establish the connection

      Set frm = New frmMDI
      Set frm.Connection = conn

However you manage to pass the recordset along, the child can access the
connection
properties via the rs.ActiveConnection property

HTH

Simeon
Ben - 31 Jul 2003 01:15 GMT
Hi Aaron-
Simeon makes some great points, and I always want to help
prevent people from making the same mistakes I have so
I'll throw in .02$ for you.

While declaring the objects as public in you MDI form is
easy, I think its not a good idea. You have no control
over how they are accesed. It is better to declare public
properties that return a reference to the object in the
MDI parent (you really don't need to create a new
connection object, you can use the one you already have).
So this would be in the MDI parent (in .NET syntax,but
I'm rusty):
Public Read Only Property Conn
 Get
   Conn = myPrivateConnection
End Property

At the same time it sounds like your data access and
presentation layers are pretty intertwined. This isn't
always bad, but it can make your code hard to maintain.
If you're loading everything you could possibly need for
your child forms into your dataset you might be using
just a bit much memory. You may want to check if a table
in the dataset and load it when you load your child form.
Alternately, you may want a class that hanldes data
access and 'serves' datasets to the forms as they are
needed.
Just stuff to think about.
HTH
Ben

>-----Original Message-----
>I am trying to create a MDI program in VB.NET 2003.  My problem is that I
[quoted text clipped - 7 lines]
>
>.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.