Q:

Does host file overrides DNS for SQLConnection?

C:\Windows\System32\drivers\etc\hosts overrides DNS for MSDOS.  For example, if you have the correct IP address in DNS and the incorrect IP address in the host file, then you will not be able to ping the domain name on the PC containing the host file.
Does this same principle work for the SQLConnection object? For example, please see the code below:
Dim objCon As New SqlConnection("Data Source=server;Initial Catalog=database;User ID=user;Password=password;MultipleActiveResultSets=True")

Will the web server connect to data source: server if the host name contains an invalid IP address for: server.

A:

Yes, the hosts file overrides anything that uses name resolution, including the SQL client (which uses standard DNS resolution).
UPDATE
If you don't present a FQDN (as you did not in your sample), then depending on the operating system(s) and the network configuration involved it may fall back to NetBIOS name resolution.  This is an old broadcast related method of resolving host names to IP addresses (it's like screaming "Hey BOB!" in your office and waiting for Bob to respond to you).  I wouldn't lean on this, but it can explain why it still seems to work when you put an invalid name in the hosts file.

