I've scoured the net for a solution to my problem and found a lot of good resources, but none that solved my issue:
http://blogs.msdn.com/sqlexpress/archive/2004/07/23/192044.aspx
http://blogs.msdn.com/sql_protocols/archive/2005/10/29/486861.aspx#51...
I have a working application that opens a local database (nothing remote) on my development machine with full-blown SQL Server 2005, but when I try the app on a machine with SQL Server 2005 Express, I get the dreaded:
"[DBNETLIB][ConnectionOpen(Connect()).]SQL Server does not exist or access denied."
My C++/ADO connection string is:
"Provider='sqloledb';Data Source='localhost';Initial Catalog='master';Integrated Security='SSPI';"
Things I've tried:
I can connect to the sqlcmd just fine. TCP, Shared, NP are all enabled. The sqlbrowser and express services are started. The OLEDB provider is correctly pointing to MS's DLL, not a rogue provider. The port (1314) is reporting in the App event log and Netstat as listening. I tried changing <localhost> to <machine name>, but it didn't help.
I did notice in the TCP/IP properties of the Server config mgr that even though TCP/IP was enabled, looking at the specific IP address showed that they were active, but disabled. After enabling port there it still didn't help...
On a hunch, I changed my provider from MDAC to Native Client with the string:
"Provider='SQLNCLI';Data Source='localhost';Initial Catalog='master';Integrated Security='SSPI';"
This gave me a more helpful error:
"[SQL Native Client]Named Pipes Provider: Could not open a connection to SQL Server [2]."
I didn't even know I was using Named Pipes! I thought it would've been defaulting to TCP/IP. Going back to the first link
(http://blogs.msdn.com/sqlexpress/archive/2004/07/23/192044.aspx) as reference and stepping through the debugging process for named pipes, I still couldn't connect with \\.\pipe\sql\query. Looking at the Application event log (Event Viewer), I saw that the named pipe, \\.\pipe\MSSQL$SQLEXPRESS\sql\query was listening.
Bingo! That did it, my app works both on the development and test machines with the connection string:
"Provider='SQLNCLI';Data Source='np:\\\\.\\pipe\\MSSQL$SQLEXPRESS\\sql\\query';Initial Catalog='master';Integrated Security='SSPI';"

Try putting /SQLEXPRESS the instance name after the localhost!