TCP/IP connection failed for SQL Server 2008 connection to host 127.0.0.1 over port 1433
1. Click Start-All Programs--Microsoft SQL Server2008---->sql server configuration manager-Select Left SQL Server 20 08 Network Configuration-double-click the MSSQLSERVER protocol and select TCP/IP right click to enable;
Configuring 1433 Ports
2. Database connection Settings
_connectionptr m_pconnection ("ADODB. Connection ");//define Database Connection object
M_pconnection.createinstance ("ADODB. Connection ");//Create Connection Object
Set the connection string, must be a BSTR type or _bstr_t type, if the database is on the network server is the shape (192.168.1.5,3340)
_bstr_t strconnect = "provider=sqloledb; SERVER=127.0.0.1,1433;DATABASE=AA; UID=AA; PWD=BB ";
HRESULT hr = M_pconnection->open (StrConnect, "", "", adModeUnknown);//null, adconnectunspecified,//Establish and server connection
This article is from the "Remote sensing application and Development" blog, please be sure to keep this source http://remotesensing.blog.51cto.com/873347/1693785
Summary of SQL Server database connectivity issues