Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Updating a Paradox record

Posted on 1998-11-11
13
Medium Priority
?
297 Views
Last Modified: 2010-04-04
How can I prevent 2 users in a network to change the same Paradox record at the same time?
0
Comment
Question by:rainbowsoftware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +2
13 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346485
hi rainbowsoftware,

you can do this by using the bde-api
by using following functions


DbiGetRecord -> set a lock

DbiIsRecordLocked -> ask for current record is locked

DbiRelRecordLock -> Release a lock

for further Details see the BDE32.HLP File. There are Delphi and C++ examples in it.

meikl
0
 
LVL 2

Expert Comment

by:SupWang
ID: 1346486
Use Exclusive to prevent other applications from accessing a Paradox or dBASE table while this application is using it. Before opening the table, set Exclusive to True.
When Exclusive is True, then when the application successfully opens the table, no other application can access it. If the table for which the application has requested exclusive access is already in use by another application, an exception is raised. To handle such exceptions, write an exception handler.

Regards,
SupWang
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346487
hi supwang,

your answer means that the table can only accessed by a single user. I mean that is not the solution, for what rainbowsoftware asked.

meikl
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rainbowsoftware
ID: 1346488
Yes, what I want is to lock a record and not a table, so the hint from Kretzschmar is showing me in the right direction, but I am unable to find an example in the HLP-file.
Could you please give me an example?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346489
hi rainbowsoftware,

here are the functionheaders, locktypes and a example from the helpfile to dbirgetrecord


LockTypes

dbiNOLOCK      No lock
dbiREADLOCK      Read lock
dbiWRITELOCK      Write lock


function DbiRelRecordLock (hCursor: hDBICur; bAll: Bool): DBIResult stdcall;

function DbiIsRecordLocked (hCursor: hDBICur; var bLocked: Bool): DBIResult stdcall;

function DbiGetRecord (hCursor: hDBICur; eLock: DBILockType; pRecBuff: Pointer; precProps: pRECProps): DBIResult stdcall;


procedure fDbiGetRecord(ATable: TTable; var RecID: Longint);
var
  CP: CurProps;
  RP: RecProps;
begin
  with ATable do begin
    // Make sure it is a Paradox table!
    UpdateCursorPos;                // sync BDE with Delphi
    // Find out if table support Seq nums or Physical Rec nums
    Check(DbiGetCursorProps(Handle, CP));
    Check(DbiGetRecord(Handle, dbiNOLOCK, nil, @RP));
    if  StrComp(CP.szTableType, szDBASE) = 0 then
      RecID := RP.iPhyRecNum

    else
      if  StrComp(CP.szTableType, szPARADOX) = 0 then
        RecID := RP.iSeqNum
      else
        // raise exception if it's not a Paradox or dBASE table
        raise EDatabaseError.Create('Not a Paradox or dBASE table');
  end;
end;

i hope its helpfull for you. to write a little example-application needs some time

meikl


0
 
LVL 1

Expert Comment

by:rpetruni
ID: 1346490
I don't know about Paradox tables, but with DBase all you have to do is to edit this record ;
Table1.Edit;
 (the record on wich you are will be locked until you release it (by posting, filtering etc.)
When a table is in Edit mode nobody else could change this record, so you really don't need to use anything else.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346491
hi  rainbowsoftware,

rpetruni has right, a writelock will be set on the current record by table.edit in paradox and dbase. I've verified it. Why complex solutions, when it's so easy.

Good Tip, rpetruni.

meikl
0
 

Expert Comment

by:elkiors
ID: 1346492
I agree, Paradox tables have auto-record locking. You can verify it easily, just create a simple app with a form containing a table grid. Now execute multiple instances of the app. As soon as the dsEdit mode becomes active, it is not possible for another instance to enter dsEdit mode. Moreover, you are automatically advised which user currently owns the record lock.
Have a play around with the multiple instances and the effects they have on one-another, I find that's the best way of seeing what's going on. The beauty of it is that it's really easy to set up a single table with an alias to act as a test bed.

Have fun

Darren
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346493
Hello? Is somebody here?
0
 

Expert Comment

by:elkiors
ID: 1346494
I'm here but only because you posted, the message.

Darren

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346495
Hello, some other here except darren?
0
 

Author Comment

by:rainbowsoftware
ID: 1346496
I have tested my application on another netvork and rpetruni is right, the record is locked for another user upon edit.
So maybe it is the network that is errorneuasly configured, so the only thing, I want to know now, is how you english-talking people are spelling the damned word errorneausly.

0
 
LVL 1

Accepted Solution

by:
rpetruni earned 300 total points
ID: 1346497
Hi,
yes this really works fine, but you have to be carefool not to filter the table or things like that after Edit, because you will cancel it by dooing so (this was my problem at first, so i was looking for an answered answer few weaks, yust to found it back again).
So when i want to lock the record i Edit the table, then i do anything i have to. If i happend to use filter after Edit, or anything that cancel it i yust repet Edit command, and so on  until Post...

I'm not English talking man, and i eawen don't know what the word errorneuasly means, so ....

Do you want to say that on your network things don't work like they should?

0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

650 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