How can I determine is it local connection (localhost or 127.0.0.1) or is it remote connection (other machine in local area) if I have SqlConnection object?
You may check SqlConnection.ConnectionString property to see if it has something like (local) or . in its' server part, but that's not very reliable because of %systemroot%\system32\drivers\etc\hosts' and various other SQL Aliases, wherebyfoo-srv` may well be a local box.