Reputation: 12437
If I have multiple server nodes all linked to a database. I want to keep track of which transactions came from which server by adding a column in the table called "ServerName". Is there something I can do in c# to get the server name, mac address or something that I can put in that column that will uniquely identify which server the transaction came from when I save my data to the database table.
Upvotes: 2
Views: 76
Reputation: 38077
If you just want the computer name you can use the MachineName property of Environment class:
Environment.MachineName
Now there is no guarantee of uniqueness of this value as multiple machines can have the same name. For many environments though, this should be good enough.
You could get at the MAC address as well, if you want, but that may be overkill for your usage.
Upvotes: 2