473,624 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capture debug.print of users logged into database

MitchR
65 New Member
I am looking to capture the Debug.print of computers connected to the backend of my database. Using the Microsoft example I can see the list of computers connected to my backend. I would like to capture the information displayed in the debug.print and send to my self in an email.
Expand|Select|Wrap|Line Numbers
  1.     'Output the list of all users in the current database.
  2.   Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
  3.     "", rs.Fields(2).Name, rs.Fields(3).Name
  4.  
  5.     While Not rs.EOF
  6.         Debug.Print rs.Fields(0), rs.Fields(1), _
  7.         rs.Fields(2), rs.Fields(3)
  8.         rs.MoveNext
  9.  
Apr 13 '11 #1
7 2617
ADezii
8,834 Recognized Expert Expert
You can build a String consisting of all the needed info, as in:
Expand|Select|Wrap|Line Numbers
  1. 'Output the list of all Users in the current database.
  2. strBuild = rs.Fields(0).name & "," & rs.Fields(1).name & "," & rs.Fields(2).name & _
  3.            "," & rs.Fields(3).name & vbCrLf
  4.  
  5. 'Add Data for each User to the String (strBuild)
  6. Do While Not rs.EOF
  7.   strBuild = strBuild & rs.Fields(0) & "," & rs.Fields(1) & "," & _
  8.              rs.Fields(2) & "," & rs.Fields(3) & vbCrLf
  9.                rs.MoveNext
  10. Loop
  11.  
  12. 'Strip ending Carriage Return/Line Feed, all needed info is now
  13. 'contained in strBuild. Place in the Body of an E-Mail Message
  14. strBuild = Left$(strBuild, Len(strBuild) - 2)
Sample OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. ShipperID,CompanyName,Phone,NoName
  2. 1,Speedy Express,(503) 555-9831,1
  3. 2,United Package,(503) 555-3199,3
  4. 3,Federal Shipping,(503) 555-9931,5
Apr 13 '11 #2
Rabbit
12,516 Recognized Expert Moderator MVP
You can send e-mail to yourself using CDO.
Apr 13 '11 #3
NeoPa
32,567 Recognized Expert Moderator MVP
Tell me if I'm off-track here, but wouldn't passing that information be more straightforward if, instead of using Debug.Print, you added the data as records to a table in your BE database. You would have the same flexibility of format and full control of whether to keep all records as a log or to process them in batches. I'd include a Date/Time value too if I were you, but you probably understand your specific requirements more precisely than I.
Apr 14 '11 #4
ADezii
8,834 Recognized Expert Expert
@NeoPa - I definitely see your point, and that was my initial approach. The way I see it, you would have to write timed code to dynamically Add and Delete Users who would be Logged On to the Back End at any given moment. Depending on what the OP is trying to achieve, it may not be worth the effort - I was thinking more or less along the lines of a Snapshot of who is Logged On at any given time. Could also be that I misread the request! (LOL).
Apr 14 '11 #5
NeoPa
32,567 Recognized Expert Moderator MVP
I wasn't considering the scheduling or triggering of any such code ADezii. It seemed to me that any time the code could run a Debug.Print, it could also run code to add a, or some, records into such a log table.

I'm sure we could also help with that if required, but I didn't read that as part of the request.
Apr 14 '11 #6
MitchR
65 New Member
My goal is to have the listing of computers connected to my back end @ 2:00am local time emailed to me. I have the lotus notes code working, and I am able to see all of the computers logged in from debug.print. Unfortunately; when I receive the email using Adezii's solution I only see one computername listed. I can see all of the headings. Let me post my entire solution.
Expand|Select|Wrap|Line Numbers
  1. Public Function ShowUserRosterMultipleUsers()
  2.     Dim cn2 As New ADODB.Connection
  3.     Dim cn As New ADODB.Connection
  4.     Dim rs As New ADODB.Recordset
  5.     Dim i, j As Long
  6.     Dim varUsers As Variant
  7.     Dim VarComputername As String
  8.     Dim MsgBody As String
  9.     Dim varState As Variant
  10.     Dim DBConnect As String
  11.  
  12.     DBConnect = "\\server\DB_be.mdb"
  13.     'Set cn = CurrentProject.Connection
  14.  
  15.  
  16.     cn.Provider = "Microsoft.Jet.OLEDB.4.0"
  17.     cn.Open "Data Source=" & DBConnect
  18.  
  19.     cn2.Provider = "Microsoft.Jet.OLEDB.4.0"
  20.     cn2.Open "Data Source=" & DBConnect
  21.  
  22.  
  23.  
  24.     ' The user roster is exposed as a provider-specific schema rowset
  25.     ' in the Jet 4.0 OLE DB provider.  You have to use a GUID to
  26.     ' reference the schema, as provider-specific schemas are not
  27.     ' listed in ADO's type library for schema rowsets
  28.  
  29.     Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
  30.     , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
  31.  
  32.  
  33. 'Output the list of all Users in the current database.
  34.  strbuild = rs.Fields(0).Name & "   " & rs.Fields(1).Name & "   " & rs.Fields(2).Name & _
  35.            "   " & rs.Fields(3).Name & vbCrLf & vbCrLf
  36.  
  37.  
  38.  
  39. 'Add Data for each User to the String (strBuild)
  40. Do While Not rs.EOF
  41.   strbuild = strbuild & rs.Fields(0) & rs.Fields(1) & _
  42.              rs.Fields(2) & rs.Fields(3) & vbCrLf
  43.                rs.MoveNext
  44. Loop
  45.  
  46.  
  47. 'Strip ending Carriage Return/Line Feed, all needed info is now
  48. 'contained in strBuild. Place in the Body of an E-Mail Message
  49. strbuild = Left$(strbuild, Len(strbuild) - 2)
  50. Debug.Print strbuild 'For Testing purposes
  51. Dim Subject As String
  52.  
  53. Dim recip(25) As Variant
  54. 'recip(1) = "Email Address1"
  55. recip(0) = "MyEmailAddress"
  56. Subject = "Notification computers Logged into Database at time of Nightly updates"
  57. MsgBody = strbuild
  58.  
  59.  
  60. Dim s As Object          
  61. Dim db As Object         
  62. Dim doc As Object        
  63. Dim sMsg As String
  64. Dim varFrom As Variant   
  65. Dim UserName As String   
  66.  
  67.     Set s = CreateObject("Notes.Notessession")       
  68.     UserName = s.UserName                               'Notes Sender
  69.     Set db = s.getDatabase("", "")                      'Set db to database not yet named
  70.     Call db.Openmail                                    'Set database to default mail database
  71.     Set doc = db.CreateDocument                         'Notesdocument '.New  '(db)   ' create a mail document
  72.     doc.Form = "Memo"                                   'Style of Lotus Form
  73.     doc.SAVEMESSAGEONSEND = True                        'Save a copy in the Sent items?
  74.  
  75.     Call doc.REPLACEITEMVALUE("From", UserName)         'Place the Senders info in message
  76.     doc.SendTo = recip                                  'Address the Email
  77.     Call doc.REPLACEITEMVALUE("Subject", Subject)       'Set The Subject
  78.     Call doc.REPLACEITEMVALUE("Body", MsgBody)          'Set the Body of the message
  79.  
  80.     doc.Send 0                                          'Send the message
  81.     doc.Visible = True
  82.  
  83.     Set s = Nothing                                     'Close connection to free memory
  84.     Set db = Nothing                                    'Cleanup
  85.     Set doc = Nothing                                   'Cleanup
  86.  
  87.  
  88. End Function
  89.  
Apr 14 '11 #7
ADezii
8,834 Recognized Expert Expert
Unless I am missing something very obvious, I see no reason why it should not work, try:
  1. Explicitly Declaring the Build Variable (Code Line #2):
    Expand|Select|Wrap|Line Numbers
    1. Dim strBuild As String
  2. Do an explicit MoveFirst within the Recordset, prior to iterating it (Code Line #12):
    Expand|Select|Wrap|Line Numbers
    1. rs.MoveFirst
    Expand|Select|Wrap|Line Numbers
    1. 'Code intentionally omitted
    2. Dim strBuild As String
    3.  
    4. Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
    5.                        , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
    6.  
    7.  
    8. 'Output the list of all Users in the current database.
    9.  strBuild = rs.Fields(0).name & "   " & rs.Fields(1).name & "   " & rs.Fields(2).name & _
    10.            "   " & rs.Fields(3).name & vbCrLf & vbCrLf
    11.  
    12. rs.MoveFirst
    13.  
    14. 'Add Data for each User to the String (strBuild)
    15. Do While Not rs.EOF
    16.   strBuild = strBuild & rs.Fields(0) & rs.Fields(1) & _
    17.              rs.Fields(2) & rs.Fields(3) & vbCrLf
    18.                rs.MoveNext
    19. Loop
    20. 'Code intentionally omitted
Apr 14 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1650
by: Octavio Alvarez | last post by:
Hi! I would like to implement a database which allows me to keep track of changes from users, but I don't know if there is any model already used for this. Let me show you what I mean. Say I have a table t_table1 with 2 columns plus a PK. Normally my table with some data would look like: t_table1 ------------------ PK | col1 | col2
3
2892
by: Tim Marshall | last post by:
For an mdb or mde release, does having debug.print without the comment single quote add any processing time to the application? I assume an mde won't since debug.prints would not be compiled in the final product, right? But in an mdb, wouldn't debug.print add a bit of processing time, however miniscule? When developing, debug.prints still active where I don't need them can
6
41952
by: Christian Blackburn | last post by:
Hi Gang, I'm wondering what the VB6 equivalent of Debug.Print is? Thanks in Advance, Christian Blackburn
5
2845
by: MLH | last post by:
I use a fair number of debug.print statements. My apps are fairly well 'peppered' with them. I've often wondered if leaving them in the mdb, creating and rolling out an mde intended for use in the A97 runtime environment might ever be cause for concern. I've noticed no symptoms to indicate a problem. Are there drawbacks to this practice?
9
10831
by: David A. Beck | last post by:
When I do a debug.print("blabla") in VB (VS2005) it doesn't show up in the output window, what gives?
6
4106
by: swartzbill2000 | last post by:
Hello, I have a VB 2005 Express project with a TraceListener-derived class to route Debug.Print output to a log file. It works fine for Debug builds. What is the correct combination of changes to make it work in Release build? Bill
5
3997
by: jjw | last post by:
I have a website that requires users to login. We track them by using sessions. We record the time and date that they login, their session id, the last page they visited, etc in a database. As as admin, I would like to be able to login and force a logout of other users logged in. Is this possible? I have looked online but there doesn't seem to be any information that addresses this.
3
1505
by: Daniel Manes | last post by:
Strangest thing, but, if I put debug.print statements in my code, they simply get ignored when I run the project. Also, if I try to put a breakpoint on a line containing debug.print, it jumps down to the next available line of code when I run the project (or jumps down immediately if the project is already running). Another thing that's stopped working is the gray highlighting that shows which blocks of code were played prior to the...
4
38263
by: Dom | last post by:
VB had a neat object called "Debug". You could use "Debug.Print()" in your code, and you could get useful debugging information in the immediate window. Is there something like this in CSharp? Dom
8
3736
by: Mike P | last post by:
What would be the best way of counting the number of users who are currently logged on to a website? I am making the users login against a database of valid users. Would the best way be to add a bool field to the table and set each user to 1 if they are logged in, and 0 if they are not logged in? *** Sent via Developersdex http://www.developersdex.com ***
0
8246
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1489
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.