内容如题,我用的是ADODC 6.0
谢谢!!

解决方案 »

  1.   

    可以试试用SetConnectionString如果不行就可以建立一个xxx.udl文件,然后以xxx.udl文件连接,通过Winexec执行这个配置文件就可以了!
      

  2.   

    CString str;
    if (m_iSel == 0)
    {
    str.Format("SELECT * FROM xjaad WHERE xjaad_ID = %i ORDER BY xjaad_xh", m_iXjID);
    }
    else
    {
    str.Format("SELECT * FROM xjaaf WHERE xjaaf_ID = %i ORDER BY xjaaf_xh", m_iXjID);
    }
    CString ConnectString;
    if (pDoc->m_UserCard.LoginAtClient)  //如果登录客户端
    {
    ConnectString.Format("Provider=MSDASQL.1;Persist Security Info=False;Data Source=%s", yourDSNName);
    m_oYGAdodc.SetConnectionString(ConnectString);
    }
    else  //如果登录的是服务器端
    {
    ConnectString.Format("Provider=MSDASQL.1;Password=%s;Persist Security Info=True;User ID=%s;Data Source=%s;Initial Catalog=jianbong", password, UserName, yourDSNName);
    m_oYGAdodc.SetConnectionString(ConnectString);
    }
    m_oYGAdodc.SetRecordSource((LPCTSTR)str);  //设置记录集
    m_oYGAdodc.Refresh();                      //重新刷新
      

  3.   

    楼上的老兄,为什么我这就不行呢,是不是ADODC控件的属性需要作什么设置或是需要作其它的初始化工作吗??
    CString m_tmp="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=DB;Data Source=localhost";m_Adodc.SetConnectionString(m_tmp);
    程序一运行到设置连接字符串就报错,不知是怎么回事
      

  4.   

    你将数据库服务提供者修改成Provider=MSDASQL.1试试呢,它也可以连接SQL Server的。