Solved

Counting Users logged into Access DataBase in Delphi

Posted on 2004-03-27
5
715 Views
Last Modified: 2010-08-05
Hi. I have converted some BDE files (Paradox) into an Access MDB and I used to have a procedure which counted the number of users logged into an application
by cloning cursors and using the BDE function "Check(DbiIsRecordLocked(Table.Handle, Locked))". This always worked great when users logged in and out, even if users crashed their OS.
I have searched about and came up with the code from Microsoft which uses OpenSchema with a SchemID which seems to not work (which I modified below).
I also checked some code which reads the LDB file, which I also have problems with as it is difficult to read this file, and anyway I dont feel its safe.

Anyone done this in Delphi already?

My test is like this so far (trying to load details into a memo), I guess I must not be understanding something :-))
I have 4 objects on a form: ADOconnection, ADOTable and a Tmemo and a Tbutton...

procedure TForm1.Button1Click(Sender: TObject);
const  SchemaID=  '{947bb102-5d43-11d1-bdbf-00c04fb92675}';
  var  Schema: TSchemaInfo;  Restrictions: OleVariant;
begin
  Schema:= siProviderSpecific;
  Restrictions:= 0; // not sure about this?
try  with ADOConn do begin
       Connected:= True;
       OpenSchema(Schema, Restrictions, SchemaID, TADODataSet(tblADO)); //crashes here so must be wrong
     end;
     with tblADO do begin
       First;
       while not EOF do begin
         AMemo.Lines.Add(Fields[0].Name);
         AMemo.Lines.Add(Fields[0].Value);
         Next;
       end;
    end;
except on e:exception do showmessage(e.message); end;
end;
0
Comment
Question by:AutoProSoftwareUK
  • 2
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
Melih SARICA earned 250 total points
ID: 10700433
Why not Creating a table for Checking Logs ?
   
Add user and Computer and type in a table when application starts.. and then when u close the applicatiion delete them from table...

or
this article would help u

http://support.microsoft.com/default.aspx?scid=kb;en-us;210331
0
 

Author Comment

by:AutoProSoftwareUK
ID: 10719205
RE:Why not Creating a table for Checking Logs ?
What if the apllication crashes?
0
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 10719370
U should put a value to registry or an ini file... when application starts

if this is set when the application starts .. it means ur app was crashed
and u can delete the log in ur table

dont forget to add the workstation name to the log table ... cuz u must check log with username and workstation .. for multi user connections

0
 

Author Comment

by:AutoProSoftwareUK
ID: 10719978
Good idea :-)
I had set a list of user names in a data file with a marker that he/she was logged in in the record, and
removed the marker when the app closed.
Problem was, if the app crashed the record was still tagged and then exceeded the "allowed user count" specified elsewhere.
Your solution will work I guess (not tried yet). Using this scenario, I assume that any file (ini, txt etc) local to each network
machine with a flag in it (e.g user name, y/n flag etc) will do, is that your idea?
0
 
LVL 6

Expert Comment

by:FactorB
ID: 24565693
Hi AutoProSoftwareUK,
I used your code as a base for other question and we made it working,
if you are interested you can check:
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_24469369.html
Regards,
B.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

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

20 Experts available now in Live!

Get 1:1 Help Now