Usually when a 'distributed environment' is mentioned in the context of a web application, it means a web farm: multiple servers running the same code where requests are load-balanced across available servers.
In the context of a database it can be an actual distributed database, but most of the time it refers to multiple copies of the same database(s), which are synchronized using what is known as replication.
The advantages are mostly redundancy and performance; there are more servers available to handle incoming requests, and if a single server fails, there are other servers available to transparently take over for that server.
You can learn about SQL Server replication here, and about IIS Web Farms here, but as to the things you need to take into account in code, I'm not able to help you.