Friday, March 30, 2012

more mystery on (local) vs localhost

ping localhost WORKS FINE
connectionString = "server=localhost;uid=sa;pwd=;database=pubs;"
FAILS
connectionString= "server=(local);uid=sa;pwd=;database=pubs;"
WORKS
C:\>osql -U sa -S localhost FAILS
Password:
[DBNETLIB]General network error. Check your network documentation.
[DBNETLIB]ConnectionRead (recv()).
C:\>isql -U sa -S localhost WORKS
Password:
1>>
> ping localhost WORKS FINE
> connectionString = "server=localhost;uid=sa;pwd=;database=pubs;"
> FAILS
> connectionString= "server=(local);uid=sa;pwd=;database=pubs;"
> WORKS
> C:\>osql -U sa -S localhost FAILS
> Password:
> [DBNETLIB]General network error. Check your network documentation.
> [DBNETLIB]ConnectionRead (recv()).
> C:\>isql -U sa -S localhost WORKS
> Password:
> 1>
--
There are known issues and bugs filed against the use of 'localhost'.
You should always use '(local)' in your connection string.
Hope this helps,
--
Eric Cárdenas
SQL Server senior support professional

No comments:

Post a Comment