Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

best way to open and close tables...

Hi All,

I have opened a Database in my mainprg.prg and run a form which access the
tables in the following form:

It may access the tables by object control.controlsource, or uses select
command, replace, via grid as well.

Now what is the best way to open/close the tables. I have lot of problems
with data environment and decided not to use for more than one table.

Any documentation or examples?

Thanks
[460 byte] By [Nimmy] at [2007-11-10 12:50:01]
# 1 Re: best way to open and close tables...
I open all my tables at the beginning of my application. I have a table with
the table names, paths, primary keys, aliases, etc. and SCAN that table and
call a custom function that takes the information from the table records and
opens each table. I don't use the form's data session at all. It's easy to
substitute test data this way.

This is just one way to handle tables. Others will have different ideas.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden@mvps.org, www.cindywinegarden.com

"Nimmy" <RemoveThisjoriveek@RemoveJUnkyahoo.com> wrote in message
news:3f0581c4@tnews.web.dev-archive.com...
> I have opened a Database in my mainprg.prg and run a form which access the
> tables in the following form:
>
> It may access the tables by object control.controlsource, or uses select
> command, replace, via grid as well.
>
> Now what is the best way to open/close the tables. I have lot of problems
> with data environment and decided not to use for more than one table.
>
> Any documentation or examples?
Cindy Winegarden at 2007-11-11 23:50:46 >
# 2 Re: best way to open and close tables...
So you don't use the DataEnvironment at all? That's a good idea. So in the
beginning, you open all the tables with use of USE Command? Where these will
be placed? in Main.Prg?

Another important questions: If you open at the beginning of the application
and don't use Data session, if you want to use control source, how you are
going to use form->textbox1(forexample)->controlsource? Because it doesn't
recognize unless you open a table with use of data session. Do you use
control source at all?

Thanks
Nimmy

"Cindy Winegarden" <cindy.winegarden@mvps.org> wrote in message
news:3f05a2b8$1@tnews.web.dev-archive.com...
> I open all my tables at the beginning of my application. I have a table
with
> the table names, paths, primary keys, aliases, etc. and SCAN that table
and
> call a custom function that takes the information from the table records
and
> opens each table. I don't use the form's data session at all. It's easy to
> substitute test data this way.
>
> This is just one way to handle tables. Others will have different ideas.
>
> --
> Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
> cindy.winegarden@mvps.org, www.cindywinegarden.com
>
> "Nimmy" <RemoveThisjoriveek@RemoveJUnkyahoo.com> wrote in message
> news:3f0581c4@tnews.web.dev-archive.com...
> > I have opened a Database in my mainprg.prg and run a form which access
the
> > tables in the following form:
> >
> > It may access the tables by object control.controlsource, or uses select
> > command, replace, via grid as well.
> >
> > Now what is the best way to open/close the tables. I have lot of
problems
> > with data environment and decided not to use for more than one table.
> >
> > Any documentation or examples?
>
>
Nimmy at 2007-11-11 23:51:43 >
# 3 Re: best way to open and close tables...
Hi Nimmy,

In my Main program, one of the first things I do is open the one table that
has all the data table names, and then I call the table opening routine
which references that table. The table opening routine uses USE and
information from the table about paths, aliases, indexes, etc.

My forms are classes and have a custom property that holds a data object.
The form controls are also a class and are all together in a container. In
the Init of the form (the data object is already instantiated) I use
AddObject to add the container with all the form controls. That means the
control sources for the various form objects exist at the time the controls
are added to the form. This technique is outlined in "Visual FoxPro 6
Enterprise Development" by Paddock, Pedersen, and Talmadge.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden@mvps.org, www.cindywinegarden.com

"Nimmy" <RemoveThisjoriveek@RemoveJUnkyahoo.com> wrote in message
news:3f092e8c$1@tnews.web.dev-archive.com...
> So you don't use the DataEnvironment at all? That's a good idea. So in the
> beginning, you open all the tables with use of USE Command? Where these
will
> be placed? in Main.Prg?
>
> Another important questions: If you open at the beginning of the
application
> and don't use Data session, if you want to use control source, how you are
> going to use form->textbox1(forexample)->controlsource? Because it doesn't
> recognize unless you open a table with use of data session. Do you use
> control source at all?
Cindy Winegarden at 2007-11-11 23:52:46 >