ADO Data Control,如何在程序中动态改变该控件的Connectionstring??? 内容如题,我用的是ADODC 6.0谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以试试用SetConnectionString如果不行就可以建立一个xxx.udl文件,然后以xxx.udl文件连接,通过Winexec执行这个配置文件就可以了! 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(); //重新刷新 楼上的老兄,为什么我这就不行呢,是不是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);程序一运行到设置连接字符串就报错,不知是怎么回事 你将数据库服务提供者修改成Provider=MSDASQL.1试试呢,它也可以连接SQL Server的。 MFC 如何实现Photoshop中的带衰减度(硬度)的线条 不知道怎么使用智能指针 花了很长时间,做了1个C++版的Hibernate 大家帮帮!!! CToolBar与CToolBarCtrl两个类有什么区别吗 在VB中取得VC做的COM组件函数的一个指针里的值 !!!!! 求助....... 编译错误C2065 ActiveX注册问题探讨 MS做图像处理的,应该好好学习GDI 求问一个SHFileOperation的问题 请问有关图片拼接(用于合成全景图)的问题? 递归函数真的很重要吗?
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(); //重新刷新
CString m_tmp="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=DB;Data Source=localhost";m_Adodc.SetConnectionString(m_tmp);
程序一运行到设置连接字符串就报错,不知是怎么回事