Una famiglia di sistemi di gestione per database relazionali di Microsoft progettati per semplificare l'uso.
ciao Francesco.
non mi è chiarissimo il tuo scenario soprattutto quanto dici dall'esterno..., ma provo a risponderti.
allora per l'utente collegato credo ti basti :
Environ("username")
per quanto al nome del computer devi ricorrere alle API.
Non credo che il nome del computer ed il nome dell'utente connesso al DB siano rilevabili uno dall'altro, ma attendo volentieri smentite, come per l'utente loggato in Windows.
prova a fare in test, copia questo codice in un maschera.
inserisci le textboxes che vedi richiamate nel codice e i commandButton che vedi richiamati nel codice, con lo stesso nome.
Fai girare il codice e vedi cosa viene scritto nelle textboxes.
ho inserito anche il nome dell'utente loggato in Windows che non centra nulla con quello loggato al DB.
Ciao, Sandro.
Option Compare Database
Option Explicit
Private Declare PtrSafe Function apiGetUserName _
Lib "Advapi32" _
Alias "GetUserNameA" ( _
ByVal Buffer As String, _
BufferSize As Long _
) As Long
Private Declare PtrSafe Function apiGetComputerName _
Lib "Kernel32" _
Alias "GetComputerNameA" ( _
ByVal Buffer As String, _
BufferSize As Long _
) As Long
Private Function mGetUserName() As String
Dim UserName As String * 255
Dim NameSize As Long
Dim RetVal As Long
NameSize = Len(UserName)
RetVal = apiGetUserName(UserName, NameSize)
mGetUserName = Left(UserName, NameSize - 1)
End Function
Private Function mGetComputerName() As String
Dim ComputerName As String * 255
Dim NameSize As Long
Dim RetVal As Long
NameSize = Len(ComputerName)
RetVal = apiGetComputerName(ComputerName, NameSize)
If RetVal > 0 Then
mGetComputerName = Left$(ComputerName, NameSize)
Else
mGetComputerName = vbNullString
End If
End Function
Private Sub cmdComputerName_Click()
txtGetComputerName = mGetComputerName()
End Sub
Private Sub cmdUserDBname_Click()
Me.loggedUSer = Environ("username")
End Sub
Private Sub cmdUserName_Click()
txtGetUserName = mGetUserName()
End Sub