Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 153
  • Last Modified:

Block a Key during the execution of a program

Hi!

I am writting a piece of code that updates my databases
when i put a txt file in a certain folder.
The presence of a new file triggers a code that reads the file, update the DB and put the file in an Archive folder.

On the other hand i use a client access to the program.
I access the DB very frequently.

My problem: it happens that i get records containing old records in some fields and new ones in other fields because the system is updating in the background my DB.

The solution seeked:I need to be able to block the refresh screen = F5 when the DB is being updated.

Is there a simple piece of code that can lock refresh and ulock it moments later?

I will definitly grade the best answer!
Thanks
0
quentin2
Asked:
quentin2
  • 7
  • 6
  • 4
  • +4
1 Solution
 
AndrewDevCommented:
What database are you using? Most databases have record locking or snapshot capability which prevents inconsistant data being read. It is one of the basics of data integrity in a database. Locks are set by the writing program and clients use the lock information to determine what to display.

Regards
Andrew
0
 
quentin2Author Commented:
Andrew,

Hum i am using Oracle,
but this is not the problem here really.

Because i just need that during the VB execution of the program which flows data into tables that the F5 key becomes unusable
 
0
 
Valliappan ANSenior Tech ConsultantCommented:
like, Where does the user presses F5 to refresh?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
AndrewDevCommented:
Not exactly what you want but:
You could set a flag in the database to indicate update in progress and then check that flag before reading the data in your client. If the flag is set either delay or cancel the read.

Be sure to clear the flag on completion of the update and if the writing program encounters any error.

I have searched MSDN for disabling F5 and refresh but without any luck. So this is the best I can come up with.

Regards
Andrew
0
 
quentin2Author Commented:

Oops i know understand the i did defined the problem properly..

Euuuh the user is accessing the Datas through a program that access the DB.
The program is the one my company owns.
It is a Trading software program

Quentin
0
 
Valliappan ANSenior Tech ConsultantCommented:
like, Where does the user presses F5 to refresh?
0
 
Valliappan ANSenior Tech ConsultantCommented:
sorry for the repost.

The system which is updating your DB, could use transactions, so that either your new changes will only be reflected in Refresh, or your old changes alone will be reflected. Not a mixed one.
0
 
Valliappan ANSenior Tech ConsultantCommented:
Is your Trading Software program, a VB source, or a 3rd party one?
0
 
quentin2Author Commented:
Unfortunately it does not

My system access an Active X dll, this piece of software updates the DB.
In the meantime it is still possible to refresh the screen and acces the DB that are being updated.
There is no possibility to disable the F5 button within the software and i am hoping to be able to make it from the dll.

Quentin
0
 
Valliappan ANSenior Tech ConsultantCommented:
>Unfortunately it does not

it does not what? it does not use transactions or does not refresh properly?

In that case are u using transactions in your activex dll, when updating the data?

cheers.
0
 
quentin2Author Commented:
it does not use transactions.
(what are transactions anyway??)

The active x is just writting to the DB and performing a few calculations

cheers
q
0
 
Valliappan ANSenior Tech ConsultantCommented:
ok, a transaction is a set of changes made to a database's data.

you could mark the beginning of a transaction with the BeginTrans statement, commit or save the transaction using the CommitTrans statement, or undo all your changes since BeginTrans by using the RollbackTrans statement.

thus before you start your updations to database you could issue a Begintrans statement, and finally issue a CommitTrans statement.

if some error occurs inbetween, optionally, you could reverse all changes by a RollBack statement.

this is supported in both ADO and DAO.
The change in usage in ADO is you should use RollbackTrans, instead of Rollback in DAO.

e.g.
Private Sub cmdUpdate_Click()
dim lTrans as boolean

On Error GoTo ErrHandle
lTrans = True
Conn1.BeginTrans
:
'your sql statements here
:
Conn1.CommitTrans
lTrans = False
exit sub

ErrHandle:
msgbox "Could not update. Error:" & err.number & " " & Err.description & " Source: " & Err.Source
If lTrans Then
  Conn1.RollbackTrans
  lTrans = False
End If
End Sub

hope this helps.
cheers.


0
 
quentin2Author Commented:
Thank you.

but i just need to freeze the F5 usage for the time my active X is being processed.

        It means i am searching for a piece
        of code which freeze the usage of the
        key, and then a piece of code to unfreeze
        it
                      OR
        something else that can fit within the
        activex  and freeze the F5


Quentin
0
 
glass_cookieCommented:
Hi!

How about hiding the whole thig until all the processing is done, then show the form again...

OR

You could set the 'Enabled' property to the form to False (activities can still be carried out at the background) then Enable the form again.

That's it!

glass cookie : )

0
 
quentin2Author Commented:
There are thousands of way to turn around i suppose...
Thanks

But i am stille searching for a way to disable F5 from a VB program.

Quentin
0
 
glass_cookieCommented:
Hi!

Does this work?

Download...
http://www.vb-helper.com/Howto/lowlevelkey.zip
Disable certain key combinations such as ALT-TAB (5K)
0
 
glass_cookieCommented:
Here's another one:

Download...
http://www.planetsourcecode.com/upload/ftp/CODE_UPLOAD1112410302000.zip
This Code will help any one to disable keyboard from response in only his program for all controls and form but not for all windows applications .please vote for me thanks ....


Download...
http://www.planetsourcecode.com/upload/ftp/CODE_UPLOAD48214152000.zip
To show what keys are on and off and to turn them on and off. this program also includes the disable X code as well as a right lcik pop up menu

That's it!

glass cookie : )

PS. Sorry... unable to test it.
0
 
glass_cookieCommented:
http://www.planetsourcecode.com/upload/ftp/Keyboard%20L2014952720.zip

     This is an updated program to my previous Keyboard Lock. It now can Lock at a certain time of day, unlockat a certain time of day, lock if the computer is Idle for x amout of minutes, and it disables your computers bootkeys. It is lightly commented. Please send comments or suggestions. Enjoy!-Sorry about uploading the wrong zip.-Fixed
 
0
 
quentin2Author Commented:
thx i'll have a look

Quentin
0
 
ArkCommented:
0
 
DanRollinsCommented:
Hi quentin2@devx,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept glass_cookie's comment(s) as an answer.

quentin2@devx, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
Computer101Commented:
Comment from expert accepted as answer

Computer101
E-E Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 6
  • 4
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now