标题:SQL2008无效的连接错误
只看楼主
charlescg
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-11-17
 问题点数:0 回复次数:1 
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;
    }
搜索更多相关主题的帖子: Network 账号 
2011-11-17 14:12
aklbryan
Rank: 2
等 级:论坛游民
帖 子:11
专家分:17
注 册:2011-11-28
得分:0 
我不会编程,但是有几个想法:

程序是在其他机器访问的话,可能要开TCP 1433和UDP 1434 端口

又或需要打开SQL Browser服务。
2011-11-28 21:16



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-355481-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.077151 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved