SQL2008无效的连接错误
安装2008后,用连接工具已经可以登陆SA账号,但是程序连接总是提示无效的连接80004005错误,程序段如下:CString strIP = ini.GetValue( "DBSetup", "IP", "127.0.0.1" );CString strDBName = ini.GetValue( "DBSetup", "DBName", "apollo" );
CString strUserName = ini.GetValue( "DBSetup", "UserName", "sa" );
CString strPassword = ini.GetValue( "DBSetup", "Password", "apollo" );
CString strConnection = _T("Provider=SQLOLEDB;Network Library=DBMSSOCN;Data Source=" + strIP \
+ ";Initial Catalog=" + strDBName \
+ ";User Id=" + strUserName \
+ ";Password=" + strPassword + ";");
if ( g_db.Open(strConnection) == FALSE )
{
CSetupSheet sheet("系统设置", NULL, 0);
if ( sheet.DoModal() != IDOK )
return FALSE;
strConnection = _T("Provider=SQLOLEDB;Network Library=DBMSSOCN;Data Source=" + sheet.m_wndDBPage.m_strIP \
+ ";Initial Catalog=" + sheet.m_wndDBPage.m_strDBName \
+ ";User Id=" + sheet.m_wndDBPage.m_strUserName \
+ ";Password=" + sheet.m_wndDBPage.m_strPassword + ";");
if ( !g_db.Open(strConnection) )
return FALSE;
}