Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: RE: List users currently using the database


Message #1 by "Ahmed Khamis" <Ahmed.Khamis@v...> on Tue, 24 Sep 2002 19:15:29 +0200
Hi all ,
Regarding to the hereunder code , can any one specify more how can I use 
it




Best regards,

Ahmed Khamis
Vodafone Egypt
Customer operation
Mob:  xxx-xxx-xxxx
Ext:56-1179
Ahmed.khamis@v...

-----Original Message-----
From: Beth Moffitt [mailto:BethMoffitt@i...]
Sent: Tuesday, August 27, 2002 3:54 PM
To: Access
Subject: [access] RE: List users currently using the database

I just saw you had the answer before hitting send, but since I prepped 
this
email, I thought maybe somebody else might benefit from the code.

Create Module with the following code:

Public Sub ShowLogInUsers() 'Jet UserRoster
    Dim cn As New ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim db As Database
    Dim rs2 As Recordset
    Dim sql As String
    Dim strCn As String
    Dim str1 As String
    Dim str2 As String

    On Error GoTo LOGerr
    Set db =3D CodeDb()
  
    strCn =3D "Data source=3D" & DBEngine.SystemDB
    cn.Provider =3D "Microsoft.Jet.OLEDB.4.0"
    cn.Open strCn
  
    ' user roster is exposed as a provider-specific schema rowset
    ' in Jet 4 OLE DB provider.  You have to use a GUID to
    ' reference the schema, as provider-specific schemas are not
    ' listed in ADO's type library for schema rowsets

    Set rs =3D cn.OpenSchema(adSchemaProviderSpecific, _
    , JET_SCHEMA_USERROSTER)
    sql =3D "select * from tblLogin where 1 =3D 2"
    Set rs2 =3D db.OpenRecordset(sql)
  
    While Not rs.EOF
        str1 =3D rs.Fields(0)
        str2 =3D rs.Fields(1)
        str3 =3D RS.Fields(2)
        str4 =3D RS.Fields(3)
        rs2.AddNew
        rs2!COMPUTER_NAME =3D str1
        rs2!LOGIN_NAME =3D str2
        rs2!CONNECTED =3D str3
        rs2!SUSPECT_STATE =3D str4
        rs2.Update
        rs.MoveNext
    Wend
  
    rs.Close
    rs2.Close
    cn.Close
    Set rs =3D Nothing
    Set rs2 =3D Nothing
    Set cn =3D Nothing
LOGerr:
    MsgBox "Error " & Err & Error$, , "Your Application"
End Sub

Create tblLogin for the fields COMPUTER_NAME, LOGIN_NAME, CONNECTED,
SUSPECT_STATE.

Create report which calls ShowLogInUsers when activated.

On report close, add:

Private Sub Report_Close()
    Dim db As Database
    Dim sqlDelete As String
    On Error Resume Next
  
    Set db =3D CodeDb()
    sqlDelete =3D "Delete * From tblLogIn"
    db.Execute (sqlDelete)
    db.Close
    Set db =3D Nothing

End Sub


Regards,

Beth Moffitt
Developer
INI, Inc.
xxx.xxx.xxxx  x110
www.iniinc.com
-----Original Message-----
From: Robeetpotts1@h... [mailto:Robeetpotts1@h...]
Sent: Tuesday, August 27, 2002 9:31 AM
To: Access
Subject: [access] List users currently using the database

Hi,

I have a secure database, and would like to product a list of those 
users
who are currently logged on to it.  Is this possible.

Rob!


Message #2 by "Gerald, Rand" <RGerald@u...> on Tue, 24 Sep 2002 13:20:57 -0500
Hi Beth,

Has the code below been tested?  It appears to mix ADO and DAO syntax
indiscriminately?  Is that your intention?

Rand E Gerald
Database Specialist
Information Services / Operations
Bah=E1'=ED National Office
1233 Central St.
Evanston IL 60201
(xxx) xxx-xxxx

-----Original Message-----
From: Beth Moffitt [mailto:BethMoffitt@i...]
Sent: Tuesday, August 27, 2002 3:54 PM
To: Access
Subject: [access] RE: List users currently using the database

I just saw you had the answer before hitting send, but since I prepped 
this
email, I thought maybe somebody else might benefit from the code.

Create Module with the following code:

Public Sub ShowLogInUsers() 'Jet UserRoster
    Dim cn As New ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim db As Database
    Dim rs2 As Recordset
    Dim sql As String
    Dim strCn As String
    Dim str1 As String
    Dim str2 As String

    On Error GoTo LOGerr
    Set db =3D CodeDb()
 
    strCn =3D "Data source=3D" & DBEngine.SystemDB
    cn.Provider =3D "Microsoft.Jet.OLEDB.4.0"
    cn.Open strCn
 
    ' user roster is exposed as a provider-specific schema rowset
    ' in Jet 4 OLE DB provider.  You have to use a GUID to
    ' reference the schema, as provider-specific schemas are not
    ' listed in ADO's type library for schema rowsets

    Set rs =3D cn.OpenSchema(adSchemaProviderSpecific, _
    , JET_SCHEMA_USERROSTER)
    sql =3D "select * from tblLogin where 1 =3D 2"
    Set rs2 =3D db.OpenRecordset(sql)
 
    While Not rs.EOF
        str1 =3D rs.Fields(0)
        str2 =3D rs.Fields(1)
        str3 =3D RS.Fields(2)
        str4 =3D RS.Fields(3)
        rs2.AddNew
        rs2!COMPUTER_NAME =3D str1
        rs2!LOGIN_NAME =3D str2
        rs2!CONNECTED =3D str3
        rs2!SUSPECT_STATE =3D str4
        rs2.Update
        rs.MoveNext
    Wend
 
    rs.Close
    rs2.Close
    cn.Close
    Set rs =3D Nothing
    Set rs2 =3D Nothing
    Set cn =3D Nothing
LOGerr:
    MsgBox "Error " & Err & Error$, , "Your Application"
End Sub

Create tblLogin for the fields COMPUTER_NAME, LOGIN_NAME, CONNECTED,
SUSPECT_STATE.

Create report which calls ShowLogInUsers when activated.

On report close, add:

Private Sub Report_Close()
    Dim db As Database
    Dim sqlDelete As String
    On Error Resume Next
 
    Set db =3D CodeDb()
    sqlDelete =3D "Delete * From tblLogIn"
    db.Execute (sqlDelete)
    db.Close
    Set db =3D Nothing

End Sub


Regards,

Beth Moffitt
Developer
INI, Inc.
xxx.xxx.xxxx  x110
www.iniinc.com
-----Original Message-----
From: Robeetpotts1@h... [mailto:Robeetpotts1@h...]
Sent: Tuesday, August 27, 2002 9:31 AM
To: Access
Subject: [access] List users currently using the database

Hi,

I have a secure database, and would like to product a list of those 
users
who are currently logged on to it.  Is this possible.

Rob!



Message #3 by Beth Moffitt <BethMoffitt@i...> on Wed, 25 Sep 2002 09:47:22 -0500
Hi Rand,

The code does work fine.  And yes, it uses ADO and DAO.

-----Original Message-----
From: Gerald, Rand [mailto:RGerald@u...]
Sent: Tuesday, September 24, 2002 1:21 PM
To: Access
Subject: [access] RE: List users currently using the database
Importance: High

Hi Beth,

Has the code below been tested?  It appears to mix ADO and DAO syntax
indiscriminately?  Is that your intention?

Rand E Gerald
Database Specialist
Information Services / Operations
Bah=E1'=ED National Office
1233 Central St.
Evanston IL 60201
(xxx) xxx-xxxx

-----Original Message-----
From: Beth Moffitt [mailto:BethMoffitt@i...]
Sent: Tuesday, August 27, 2002 3:54 PM
To: Access
Subject: [access] RE: List users currently using the database

I just saw you had the answer before hitting send, but since I prepped 
this
email, I thought maybe somebody else might benefit from the code.

Create Module with the following code:

Public Sub ShowLogInUsers() 'Jet UserRoster
    Dim cn As New ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim db As Database
    Dim rs2 As Recordset
    Dim sql As String
    Dim strCn As String
    Dim str1 As String
    Dim str2 As String

    On Error GoTo LOGerr
    Set db =3D CodeDb()
 
    strCn =3D "Data source=3D" & DBEngine.SystemDB
    cn.Provider =3D "Microsoft.Jet.OLEDB.4.0"
    cn.Open strCn
 
    ' user roster is exposed as a provider-specific schema rowset
    ' in Jet 4 OLE DB provider.  You have to use a GUID to
    ' reference the schema, as provider-specific schemas are not
    ' listed in ADO's type library for schema rowsets

    Set rs =3D cn.OpenSchema(adSchemaProviderSpecific, _
    , JET_SCHEMA_USERROSTER)
    sql =3D "select * from tblLogin where 1 =3D 2"
    Set rs2 =3D db.OpenRecordset(sql)
 
    While Not rs.EOF
        str1 =3D rs.Fields(0)
        str2 =3D rs.Fields(1)
        str3 =3D RS.Fields(2)
        str4 =3D RS.Fields(3)
        rs2.AddNew
        rs2!COMPUTER_NAME =3D str1
        rs2!LOGIN_NAME =3D str2
        rs2!CONNECTED =3D str3
        rs2!SUSPECT_STATE =3D str4
        rs2.Update
        rs.MoveNext
    Wend
 
    rs.Close
    rs2.Close
    cn.Close
    Set rs =3D Nothing
    Set rs2 =3D Nothing
    Set cn =3D Nothing
LOGerr:
    MsgBox "Error " & Err & Error$, , "Your Application"
End Sub

Create tblLogin for the fields COMPUTER_NAME, LOGIN_NAME, CONNECTED,
SUSPECT_STATE.

Create report which calls ShowLogInUsers when activated.

On report close, add:

Private Sub Report_Close()
    Dim db As Database
    Dim sqlDelete As String
    On Error Resume Next
 
    Set db =3D CodeDb()
    sqlDelete =3D "Delete * From tblLogIn"
    db.Execute (sqlDelete)
    db.Close
    Set db =3D Nothing

End Sub


Regards,

Beth Moffitt
Developer
INI, Inc.
xxx.xxx.xxxx  x110
www.iniinc.com
-----Original Message-----
From: Robeetpotts1@h... [mailto:Robeetpotts1@h...]
Sent: Tuesday, August 27, 2002 9:31 AM
To: Access
Subject: [access] List users currently using the database

Hi,

I have a secure database, and would like to product a list of those 
users
who are currently logged on to it.  Is this possible.

Rob!




Message #4 by "Gerald, Rand" <RGerald@u...> on Wed, 25 Sep 2002 09:57:13 -0500
When I tried to test it, the code choked on the constant
JET_SCHEMA_USERROSTER.  Where is it defined?

Rand E Gerald
Database Specialist
Information Services / Operations
Bah=E1'=ED National Office
1233 Central St.
Evanston IL 60201
(xxx) xxx-xxxx

-----Original Message-----
From: Beth Moffitt [mailto:BethMoffitt@i...]
Sent: Wednesday, September 25, 2002 9:47 AM
To: Access
Subject: [access] RE: List users currently using the database

Hi Rand,

The code does work fine.  And yes, it uses ADO and DAO.

-----Original Message-----
From: Gerald, Rand [mailto:RGerald@u...]
Sent: Tuesday, September 24, 2002 1:21 PM
To: Access
Subject: [access] RE: List users currently using the database
Importance: High

Hi Beth,

Has the code below been tested?  It appears to mix ADO and DAO syntax
indiscriminately?  Is that your intention?

Rand E Gerald
Database Specialist
Information Services / Operations
Bah=E1'=ED National Office
1233 Central St.
Evanston IL 60201
(xxx) xxx-xxxx

-----Original Message-----
From: Beth Moffitt [mailto:BethMoffitt@i...]
Sent: Tuesday, August 27, 2002 3:54 PM
To: Access
Subject: [access] RE: List users currently using the database

I just saw you had the answer before hitting send, but since I prepped 
this
email, I thought maybe somebody else might benefit from the code.

Create Module with the following code:

Public Sub ShowLogInUsers() 'Jet UserRoster
    Dim cn As New ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim db As Database
    Dim rs2 As Recordset
    Dim sql As String
    Dim strCn As String
    Dim str1 As String
    Dim str2 As String

    On Error GoTo LOGerr
    Set db =3D CodeDb()

    strCn =3D "Data source=3D" & DBEngine.SystemDB
    cn.Provider =3D "Microsoft.Jet.OLEDB.4.0"
    cn.Open strCn

    ' user roster is exposed as a provider-specific schema rowset
    ' in Jet 4 OLE DB provider.  You have to use a GUID to
    ' reference the schema, as provider-specific schemas are not
    ' listed in ADO's type library for schema rowsets

    Set rs =3D cn.OpenSchema(adSchemaProviderSpecific, _
    , JET_SCHEMA_USERROSTER)
    sql =3D "select * from tblLogin where 1 =3D 2"
    Set rs2 =3D db.OpenRecordset(sql)

    While Not rs.EOF
        str1 =3D rs.Fields(0)
        str2 =3D rs.Fields(1)
        str3 =3D RS.Fields(2)
        str4 =3D RS.Fields(3)
        rs2.AddNew
        rs2!COMPUTER_NAME =3D str1
        rs2!LOGIN_NAME =3D str2
        rs2!CONNECTED =3D str3
        rs2!SUSPECT_STATE =3D str4
        rs2.Update
        rs.MoveNext
    Wend

    rs.Close
    rs2.Close
    cn.Close
    Set rs =3D Nothing
    Set rs2 =3D Nothing
    Set cn =3D Nothing
LOGerr:
    MsgBox "Error " & Err & Error$, , "Your Application"
End Sub

Create tblLogin for the fields COMPUTER_NAME, LOGIN_NAME, CONNECTED,
SUSPECT_STATE.

Create report which calls ShowLogInUsers when activated.

On report close, add:

Private Sub Report_Close()
    Dim db As Database
    Dim sqlDelete As String
    On Error Resume Next

    Set db =3D CodeDb()
    sqlDelete =3D "Delete * From tblLogIn"
    db.Execute (sqlDelete)
    db.Close
    Set db =3D Nothing

End Sub


Regards,

Beth Moffitt
Developer
INI, Inc.
xxx.xxx.xxxx  x110
www.iniinc.com
-----Original Message-----
From: Robeetpotts1@h... [mailto:Robeetpotts1@h...]
Sent: Tuesday, August 27, 2002 9:31 AM
To: Access
Subject: [access] List users currently using the database

Hi,

I have a secure database, and would like to product a list of those 
users
who are currently logged on to it.  Is this possible.

Rob!





Message #5 by Beth Moffitt <BethMoffitt@i...> on Wed, 25 Sep 2002 11:50:57 -0500
As noted below:

    ' user roster is exposed as a provider-specific schema rowset
    ' in Jet 4 OLE DB provider.  You have to use a GUID to
    ' reference the schema, as provider-specific schemas are not
    ' listed in ADO's type library for schema rowsets

Rand,  I didn't write this, I just use it.  <grin>


-----Original Message-----
From: Gerald, Rand [mailto:RGerald@u...]
Sent: Wednesday, September 25, 2002 9:57 AM
To: Access
Subject: [access] RE: List users currently using the database
Importance: High

When I tried to test it, the code choked on the constant
JET_SCHEMA_USERROSTER.  Where is it defined?

Rand E Gerald
Database Specialist
Information Services / Operations
Bah=E1'=ED National Office
1233 Central St.
Evanston IL 60201
(xxx) xxx-xxxx

-----Original Message-----
From: Beth Moffitt [mailto:BethMoffitt@i...]
Sent: Wednesday, September 25, 2002 9:47 AM
To: Access
Subject: [access] RE: List users currently using the database

Hi Rand,

The code does work fine.  And yes, it uses ADO and DAO.

-----Original Message-----
From: Gerald, Rand [mailto:RGerald@u...]
Sent: Tuesday, September 24, 2002 1:21 PM
To: Access
Subject: [access] RE: List users currently using the database
Importance: High

Hi Beth,

Has the code below been tested?  It appears to mix ADO and DAO syntax
indiscriminately?  Is that your intention?

Rand E Gerald
Database Specialist
Information Services / Operations
Bah=E1'=ED National Office
1233 Central St.
Evanston IL 60201
(xxx) xxx-xxxx

-----Original Message-----
From: Beth Moffitt [mailto:BethMoffitt@i...]
Sent: Tuesday, August 27, 2002 3:54 PM
To: Access
Subject: [access] RE: List users currently using the database

I just saw you had the answer before hitting send, but since I prepped 
this
email, I thought maybe somebody else might benefit from the code.

Create Module with the following code:

Public Sub ShowLogInUsers() 'Jet UserRoster
    Dim cn As New ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim db As Database
    Dim rs2 As Recordset
    Dim sql As String
    Dim strCn As String
    Dim str1 As String
    Dim str2 As String

    On Error GoTo LOGerr
    Set db =3D CodeDb()

    strCn =3D "Data source=3D" & DBEngine.SystemDB
    cn.Provider =3D "Microsoft.Jet.OLEDB.4.0"
    cn.Open strCn

    ' user roster is exposed as a provider-specific schema rowset
    ' in Jet 4 OLE DB provider.  You have to use a GUID to
    ' reference the schema, as provider-specific schemas are not
    ' listed in ADO's type library for schema rowsets

    Set rs =3D cn.OpenSchema(adSchemaProviderSpecific, _
    , JET_SCHEMA_USERROSTER)
    sql =3D "select * from tblLogin where 1 =3D 2"
    Set rs2 =3D db.OpenRecordset(sql)

    While Not rs.EOF
        str1 =3D rs.Fields(0)
        str2 =3D rs.Fields(1)
        str3 =3D RS.Fields(2)
        str4 =3D RS.Fields(3)
        rs2.AddNew
        rs2!COMPUTER_NAME =3D str1
        rs2!LOGIN_NAME =3D str2
        rs2!CONNECTED =3D str3
        rs2!SUSPECT_STATE =3D str4
        rs2.Update
        rs.MoveNext
    Wend

    rs.Close
    rs2.Close
    cn.Close
    Set rs =3D Nothing
    Set rs2 =3D Nothing
    Set cn =3D Nothing
LOGerr:
    MsgBox "Error " & Err & Error$, , "Your Application"
End Sub

Create tblLogin for the fields COMPUTER_NAME, LOGIN_NAME, CONNECTED,
SUSPECT_STATE.

Create report which calls ShowLogInUsers when activated.

On report close, add:

Private Sub Report_Close()
    Dim db As Database
    Dim sqlDelete As String
    On Error Resume Next

    Set db =3D CodeDb()
    sqlDelete =3D "Delete * From tblLogIn"
    db.Execute (sqlDelete)
    db.Close
    Set db =3D Nothing

End Sub


Regards,

Beth Moffitt
Developer
INI, Inc.
xxx.xxx.xxxx  x110
www.iniinc.com
-----Original Message-----
From: Robeetpotts1@h... [mailto:Robeetpotts1@h...]
Sent: Tuesday, August 27, 2002 9:31 AM
To: Access
Subject: [access] List users currently using the database

Hi,

I have a secure database, and would like to product a list of those 
users
who are currently logged on to it.  Is this possible.

Rob!







  Return to Index