Solved

Block a Key during the execution of a program

Posted on 2001-06-13
22
143 Views
Last Modified: 2010-05-02
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
Comment
Question by:quentin2
  • 7
  • 6
  • 4
  • +4
22 Comments
 
LVL 5

Expert Comment

by:AndrewDev
ID: 6185221
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
 

Author Comment

by:quentin2
ID: 6185264
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
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6185312
like, Where does the user presses F5 to refresh?
0
 
LVL 5

Expert Comment

by:AndrewDev
ID: 6185320
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
 

Author Comment

by:quentin2
ID: 6185328

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
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6185350
like, Where does the user presses F5 to refresh?
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6185354
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
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6185369
Is your Trading Software program, a VB source, or a 3rd party one?
0
 

Author Comment

by:quentin2
ID: 6185377
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
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6185411
>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
 

Author Comment

by:quentin2
ID: 6185433
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6185506
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
 

Author Comment

by:quentin2
ID: 6185530
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
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6186551
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
 

Author Comment

by:quentin2
ID: 6186588
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
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6186649
Hi!

Does this work?

Download...
http://www.vb-helper.com/Howto/lowlevelkey.zip
Disable certain key combinations such as ALT-TAB (5K)
0
 
LVL 8

Accepted Solution

by:
glass_cookie earned 160 total points
ID: 6186669
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
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6186675
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
 

Author Comment

by:quentin2
ID: 6186773
thx i'll have a look

Quentin
0
 
LVL 27

Expert Comment

by:Ark
ID: 6189075
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7136027
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
 
LVL 1

Expert Comment

by:Computer101
ID: 7168459
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now