Solved

find computer/user using a database file

Posted on 2002-03-26
12
154 Views
Last Modified: 2010-04-04
Hi,

In a multi user environment is it possible to identify the computer or user that is using a database file. IE I have a multi user system where at times there is a need to open the files exclusively (eg rebuild indexes), but when trying to open the files exclusively I can't because someone else is in the system - How can I identify who this is so that I can locate this user and ask them to exit the system.

Thanks
Clyde
0
Comment
Question by:clyde99
[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
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6898378
I guess it depends on the type of database you're using.  MS SQL for instance only uses one file to hold all the tables, so the only way you'll be able to find out who's accessing them is to query the database system.

If you're accessing the database through an ODBC driver, then that may make it even more difficult that accessing it directly as the ODBC driver could contain the login details for one account and therefore be not user specific.

My guess would be, find out what database you are using, and then see if there's any APIs for it floating around.  If there are, you're chances of success are a lot greater.

Stu
0
 

Author Comment

by:clyde99
ID: 6898510
Thanks stu,

I am using the BDE with dbase tables - Any way you know of getting this information from the BDE?

Thanks
Clyde
0
 
LVL 1

Expert Comment

by:Summa
ID: 6898645
Hi,

as far as I know this is only possible with
Paradox .db files. But I'm not sure...

Maybe this can help you.


a function for paradox-tables.
==============================================

uses BDE, ....;

....

procedure GetTableUsers(ATable: TTable; AStrings: TStrings);
var
  TmpCursor: hdbicur;
  LockInfo: LOCKDesc;
  Status: dbiResult;
begin
  Check(DbiOpenLockList(aTable.Handle, True, True, TmpCursor));
  Check(DbiSetToBegin(TmpCursor));
  Repeat
    Status := DbiGetNextRecord(TmpCursor, dbiNOLOCK, @LockInfo, Nil);
    AStrings.Add(LockInfo.szUserName);
  Until (Status <> DBIERR_NONE);
  Check(DbiCloseCursor(TmpCursor));
  Check(DbiCloseCursor(TmpCursor));
end;
0
Industry Leaders: 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!

 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6898811
Hi Clyde,

I'm fairly sure you'll find Summa's suggestion will work with dBase tables.  I guess there is only one way to know for sure :)

Summa.  Can I ask where you obtained that code?  I quite often need a few low level DB routines and if it's from a library, I'd be interested to know where to get it.

Cheers folks,

Stu
0
 

Author Comment

by:clyde99
ID: 6899036
Hi Summa,

Thanks for the code snippet.

Unfortunately when I tried with a dbase file, the BDE came up with the exception error "Project1.exe raised exception class EDBEngineError with message 'Capability not supported'"

So it looks like this will not work with BDE and Dbase files.

Looks like I may have come to a dead end here unless anyone else has some other ideas?

Clyde
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6900479
Hi Clyde,

I had a thought last night.  Are the tables being served from an NT/2000/XP box?  If so, there is an administration tool which allows you to see who has what files open.  Perhaps there is a way you can find some info on what APIs that application uses and implement them in your program?  There was a big write up in The Delphi Magazine a few months ago about the Active Directory.  I believe there is ways of finding this sort of info out use the Active Directory.  I don't have the mag with me, but will check tonight and let you know.

Stu
0
 

Author Comment

by:clyde99
ID: 6901029
Hi Stu,

Yes, the Dbase files are on a Windows 2000 Server box(but I am not using active directory). However, I have used the admin tool that you refer to and If I could get access to that information via some API then that would solve my problem.

Thanks
Clyde
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6901048
Hi Clyde,

Does the admin tool show who's logged in, or is it just showing a generic (say SYSTEM) account??

I'll have a look for the info on Active Directories tonight and post you anything relevant.  You can actually go to their website and download previous issues cover disks, so if I give you the issue number, you'll be able to get the source code for it.

Stu
0
 

Author Comment

by:clyde99
ID: 6901140
Hi Stu,

The admin tool I refer to is "Computer Management" (from the control panel). When you drill down in this tool from "System Tools", then "Shared Folders", Through a combination of "Shares" and "Open Files" is all the information I need.

Clyde
0
 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 100 total points
ID: 6901350
Hi Clyde,

No worries, mate.  Let's see if that article can help you or not.  I'll be home from work in about 4 hours, so I'll post something as soon as I locate it.

Stu
0
 
LVL 1

Expert Comment

by:Summa
ID: 6902127
for STU:
==========

>Summa.  Can I ask where you obtained that code?  I quite >often need a few low level DB routines and
>if it's from a library, I'd be interested to know where >to get it.

I found that snippet somewhere, but can't remember
the URL. Such BDE routines are very hard to find.
Look at the BDE-Help, there are some samples in it.


0
 

Expert Comment

by:CleanupPing
ID: 9343213
clyde99:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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