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. -
'Output the list of all users in the current database.
-
Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
-
"", rs.Fields(2).Name, rs.Fields(3).Name
-
-
While Not rs.EOF
-
Debug.Print rs.Fields(0), rs.Fields(1), _
-
rs.Fields(2), rs.Fields(3)
-
rs.MoveNext
-
7 2617 ADezii 8,834
Recognized Expert Expert
You can build a String consisting of all the needed info, as in: - 'Output the list of all Users in the current database.
-
strBuild = rs.Fields(0).name & "," & rs.Fields(1).name & "," & rs.Fields(2).name & _
-
"," & rs.Fields(3).name & vbCrLf
-
-
'Add Data for each User to the String (strBuild)
-
Do While Not rs.EOF
-
strBuild = strBuild & rs.Fields(0) & "," & rs.Fields(1) & "," & _
-
rs.Fields(2) & "," & rs.Fields(3) & vbCrLf
-
rs.MoveNext
-
Loop
-
-
'Strip ending Carriage Return/Line Feed, all needed info is now
-
'contained in strBuild. Place in the Body of an E-Mail Message
-
strBuild = Left$(strBuild, Len(strBuild) - 2)
Sample OUTPUT: - ShipperID,CompanyName,Phone,NoName
-
1,Speedy Express,(503) 555-9831,1
-
2,United Package,(503) 555-3199,3
-
3,Federal Shipping,(503) 555-9931,5
Rabbit 12,516
Recognized Expert Moderator MVP
You can send e-mail to yourself using CDO.
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.
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).
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.
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. -
Public Function ShowUserRosterMultipleUsers()
-
Dim cn2 As New ADODB.Connection
-
Dim cn As New ADODB.Connection
-
Dim rs As New ADODB.Recordset
-
Dim i, j As Long
-
Dim varUsers As Variant
-
Dim VarComputername As String
-
Dim MsgBody As String
-
Dim varState As Variant
-
Dim DBConnect As String
-
-
DBConnect = "\\server\DB_be.mdb"
-
'Set cn = CurrentProject.Connection
-
-
-
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
-
cn.Open "Data Source=" & DBConnect
-
-
cn2.Provider = "Microsoft.Jet.OLEDB.4.0"
-
cn2.Open "Data Source=" & DBConnect
-
-
-
-
' The user roster is exposed as a provider-specific schema rowset
-
' in the Jet 4.0 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 = cn.OpenSchema(adSchemaProviderSpecific, _
-
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
-
-
-
'Output the list of all Users in the current database.
-
strbuild = rs.Fields(0).Name & " " & rs.Fields(1).Name & " " & rs.Fields(2).Name & _
-
" " & rs.Fields(3).Name & vbCrLf & vbCrLf
-
-
-
-
'Add Data for each User to the String (strBuild)
-
Do While Not rs.EOF
-
strbuild = strbuild & rs.Fields(0) & rs.Fields(1) & _
-
rs.Fields(2) & rs.Fields(3) & vbCrLf
-
rs.MoveNext
-
Loop
-
-
-
'Strip ending Carriage Return/Line Feed, all needed info is now
-
'contained in strBuild. Place in the Body of an E-Mail Message
-
strbuild = Left$(strbuild, Len(strbuild) - 2)
-
Debug.Print strbuild 'For Testing purposes
-
Dim Subject As String
-
-
Dim recip(25) As Variant
-
'recip(1) = "Email Address1"
-
recip(0) = "MyEmailAddress"
-
Subject = "Notification computers Logged into Database at time of Nightly updates"
-
MsgBody = strbuild
-
-
-
Dim s As Object
-
Dim db As Object
-
Dim doc As Object
-
Dim sMsg As String
-
Dim varFrom As Variant
-
Dim UserName As String
-
-
Set s = CreateObject("Notes.Notessession")
-
UserName = s.UserName 'Notes Sender
-
Set db = s.getDatabase("", "") 'Set db to database not yet named
-
Call db.Openmail 'Set database to default mail database
-
Set doc = db.CreateDocument 'Notesdocument '.New '(db) ' create a mail document
-
doc.Form = "Memo" 'Style of Lotus Form
-
doc.SAVEMESSAGEONSEND = True 'Save a copy in the Sent items?
-
-
Call doc.REPLACEITEMVALUE("From", UserName) 'Place the Senders info in message
-
doc.SendTo = recip 'Address the Email
-
Call doc.REPLACEITEMVALUE("Subject", Subject) 'Set The Subject
-
Call doc.REPLACEITEMVALUE("Body", MsgBody) 'Set the Body of the message
-
-
doc.Send 0 'Send the message
-
doc.Visible = True
-
-
Set s = Nothing 'Close connection to free memory
-
Set db = Nothing 'Cleanup
-
Set doc = Nothing 'Cleanup
-
-
-
End Function
-
ADezii 8,834
Recognized Expert Expert
Unless I am missing something very obvious, I see no reason why it should not work, try: - Explicitly Declaring the Build Variable (Code Line #2):
- Do an explicit MoveFirst within the Recordset, prior to iterating it (Code Line #12):
- 'Code intentionally omitted
-
Dim strBuild As String
-
-
Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
-
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
-
-
-
'Output the list of all Users in the current database.
-
strBuild = rs.Fields(0).name & " " & rs.Fields(1).name & " " & rs.Fields(2).name & _
-
" " & rs.Fields(3).name & vbCrLf & vbCrLf
-
-
rs.MoveFirst
-
-
'Add Data for each User to the String (strBuild)
-
Do While Not rs.EOF
-
strBuild = strBuild & rs.Fields(0) & rs.Fields(1) & _
-
rs.Fields(2) & rs.Fields(3) & vbCrLf
-
rs.MoveNext
-
Loop
-
'Code intentionally omitted
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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
|
by: Christian Blackburn |
last post by:
Hi Gang,
I'm wondering what the VB6 equivalent of Debug.Print is?
Thanks in Advance,
Christian Blackburn
|
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?
|
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?
| |
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
|
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.
|
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...
|
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
|
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 ***
|
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...
| |
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,...
|
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,...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |