good programming practice!!?? and VB controls

good programming practice!!?? and VB controls

Post by ben dove » Sun, 08 Dec 2002 06:32:08



Hi

I have  a small problem with the application I am busy with.I have and
msflexgrid and before the form exists it saves the selected row to the DB
using an update statement, this db entry is used in the next form and is
requested using a select statement. My problem is that sometimes the update
takes longer than the other form loading and selectinmg the Db entry
therefore it doesnt get selected. I need some advice on which controls to
use to ensure that the appropriate time is taken to let the update statement
take place and therefore the correct info selected. Should I make use of a
different mouse cursor? or should i make a small form with a progress bar on
it? But what I am trying to get my head around is the following: how do I
know when the statement is completely updated?is there anyway of determining
from the DB when it is complete? I am using and access database and
ADO.Another factor is also when the db increases will it affect the
update/insert time??

thanx in advance!

ben

 
 
 

good programming practice!!?? and VB controls

Post by Steve Rowel » Sat, 07 Dec 2002 21:04:16


If you declare your connection object using WithEvents you will expose the
events for the connection:

This declaration must be in a form or class module:

Private WithEvents cnn As ADODB.Connection

When declared this way, the connection name will be in the objects combobox
and its events will be in the events combo-box.
The following event will fire when your query to the database has completed
and is ready to use.

Private Sub cnn_ExecuteComplete(ByVal RecordsAffected As Long, ByVal pError
As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pCommand As
ADODB.Command, ByVal pRecordset As ADODB.Recordset, ByVal pConnection As
ADODB.Connection)

hth,
s


Quote:> Hi

> I have  a small problem with the application I am busy with.I have and
> msflexgrid and before the form exists it saves the selected row to the DB
> using an update statement, this db entry is used in the next form and is
> requested using a select statement. My problem is that sometimes the
update
> takes longer than the other form loading and selectinmg the Db entry
> therefore it doesnt get selected. I need some advice on which controls to
> use to ensure that the appropriate time is taken to let the update
statement
> take place and therefore the correct info selected. Should I make use of a
> different mouse cursor? or should i make a small form with a progress bar
on
> it? But what I am trying to get my head around is the following: how do I
> know when the statement is completely updated?is there anyway of
determining
> from the DB when it is complete? I am using and access database and
> ADO.Another factor is also when the db increases will it affect the
> update/insert time??

> thanx in advance!

> ben


 
 
 

good programming practice!!?? and VB controls

Post by David Wimbu » Mon, 09 Dec 2002 17:32:21


How are you doing this update and where? If you execute SQL to update
the database before you call up the second form it should happen in
sequence. The update should finish before control returns to your
program and then your code will load the form. Are you maybe doing the
update in the form's Load event?

> If you declare your connection object using WithEvents you will expose the
> events for the connection:

> This declaration must be in a form or class module:

> Private WithEvents cnn As ADODB.Connection

> When declared this way, the connection name will be in the objects combobox
> and its events will be in the events combo-box.
> The following event will fire when your query to the database has completed
> and is ready to use.

> Private Sub cnn_ExecuteComplete(ByVal RecordsAffected As Long, ByVal pError
> As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pCommand As
> ADODB.Command, ByVal pRecordset As ADODB.Recordset, ByVal pConnection As
> ADODB.Connection)

> hth,
> s



> > Hi

> > I have  a small problem with the application I am busy with.I have and
> > msflexgrid and before the form exists it saves the selected row to the DB
> > using an update statement, this db entry is used in the next form and is
> > requested using a select statement. My problem is that sometimes the
>  update
> > takes longer than the other form loading and selectinmg the Db entry
> > therefore it doesnt get selected. I need some advice on which controls to
> > use to ensure that the appropriate time is taken to let the update
>  statement
> > take place and therefore the correct info selected. Should I make use of a
> > different mouse cursor? or should i make a small form with a progress bar
>  on
> > it? But what I am trying to get my head around is the following: how do I
> > know when the statement is completely updated?is there anyway of
>  determining
> > from the DB when it is complete? I am using and access database and
> > ADO.Another factor is also when the db increases will it affect the
> > update/insert time??

> > thanx in advance!

> > ben

 
 
 

good programming practice!!?? and VB controls

Post by ben dove » Wed, 11 Dec 2002 02:29:48


I do the update in the form_unload event.

It should do the update in sequence but it appears that the insert/update
take long at times and the following select statement doesnt seem to
retrieve the latest updated/inserted info in the DB.


> How are you doing this update and where? If you execute SQL to update
> the database before you call up the second form it should happen in
> sequence. The update should finish before control returns to your
> program and then your code will load the form. Are you maybe doing the
> update in the form's Load event?




> > If you declare your connection object using WithEvents you will expose
the
> > events for the connection:

> > This declaration must be in a form or class module:

> > Private WithEvents cnn As ADODB.Connection

> > When declared this way, the connection name will be in the objects
combobox
> > and its events will be in the events combo-box.
> > The following event will fire when your query to the database has
completed
> > and is ready to use.

> > Private Sub cnn_ExecuteComplete(ByVal RecordsAffected As Long, ByVal
pError
> > As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pCommand As
> > ADODB.Command, ByVal pRecordset As ADODB.Recordset, ByVal pConnection As
> > ADODB.Connection)

> > hth,
> > s



> > > Hi

> > > I have  a small problem with the application I am busy with.I have and
> > > msflexgrid and before the form exists it saves the selected row to the
DB
> > > using an update statement, this db entry is used in the next form and
is
> > > requested using a select statement. My problem is that sometimes the
> >  update
> > > takes longer than the other form loading and selectinmg the Db entry
> > > therefore it doesnt get selected. I need some advice on which controls
to
> > > use to ensure that the appropriate time is taken to let the update
> >  statement
> > > take place and therefore the correct info selected. Should I make use
of a
> > > different mouse cursor? or should i make a small form with a progress
bar
> >  on
> > > it? But what I am trying to get my head around is the following: how
do I
> > > know when the statement is completely updated?is there anyway of
> >  determining
> > > from the DB when it is complete? I am using and access database and
> > > ADO.Another factor is also when the db increases will it affect the
> > > update/insert time??

> > > thanx in advance!

> > > ben