[Solved] Base Mysql get username + hostname

dBase, Calc, CSV, MS ACCESS, MySQL, PostgrSQL, OTHER
Post Reply
ponlerd
Posts: 56
Joined: Sun Nov 15, 2009 6:22 pm
Location: Bangkok, Thailand

[Solved] Base Mysql get username + hostname

Post by ponlerd »

Hi, is there a way that i can get the username and hostname in a macro?
I want to stamp the user@hostname on some records.
For the username i can get it from
Form.ActiveConnection.Parent.User (if i remember it right.)

But for the hostname , i couldn't find it anywhere on the xRay.
Thanks!
Last edited by ponlerd on Fri Apr 30, 2010 4:25 am, edited 1 time in total.
OOo 3.2 Ubuntu 9.04 / OOo 3.2 Windows7 / Migrating from Access
rudolfo
Volunteer
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Base Mysql get username + hostname

Post by rudolfo »

You use MySQL in your title and the format user@hostname sounds like MySQL as well.
So my advice is: "Ask the database for this information:"

Code: Select all

mysql> select user();
+----------------+
| user()         |
+----------------+
| rolf@localhost |
+----------------+
If I do the same inside a query in Base on my Windows machine connected to a MySQL database on a Linux Box I get: rolf@grappa.ristaurante.local as the resulting record.
Actually this is information about the client side of the connection. But as you say you need to stamp it, the client machine makes much more sense than the host name with the mysql server.

update this_table set changed_by = user() where ....

And see the Mysql manual in case you need other types of session data.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
ponlerd
Posts: 56
Joined: Sun Nov 15, 2009 6:22 pm
Location: Bangkok, Thailand

Re: Base Mysql get username + hostname

Post by ponlerd »

Thanks , works great!
OOo 3.2 Ubuntu 9.04 / OOo 3.2 Windows7 / Migrating from Access
Post Reply