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

x
?
Solved

find computer/user using a database file

Posted on 2002-03-26
12
Medium Priority
?
165 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 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

618 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