vc 6.0 MFC 连接SQL SERVER2008

Dreamer558 2018-11-20 06:32:18

难道是数据库权限有问题??





找不到这个函数是怎么回事?



...全文
172 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zgl7903 2018-11-22
  • 打赏
  • 举报
回复
看不到错误代码啊, 把错误信息 百度 百度




blackangelboy 2018-11-22
  • 打赏
  • 举报
回复
这两个我写的程序源代码里面几乎有你所要的全套SQL数据库的操作!
连接、增删改查 排序 汇总 分析 逻辑运算 等等等等
黑男服装ERP生产管理软件源代码
https://blog.csdn.net/blackangelboy/article/details/84346296
再送你一个我最近写的鼠标连点器的源代码!
https://blog.csdn.net/blackangelboy/article/details/84343862
blackangelboy 2018-11-22
  • 打赏
  • 举报
回复
给你推荐一个我写的完整的VC++fmc连接操作SqlSERVER2008R2数据库的例子
你下过去慢慢研究研究就行了

黑男服装ERP生产管理软件源代码(黑男双十一超级大出血!大跳楼!大爆炸赠送给广大编程爱好者的整套源代码!)
https://blog.csdn.net/blackangelboy/article/details/84346296

给大家赠送一个我最近写的鼠标连点器的源代码!
https://blog.csdn.net/blackangelboy/article/details/84343862
blackangelboy 2018-11-22
  • 打赏
  • 举报
回复
我来直接给你贴完整代码!
stdafx.h 中加如下代码
#import "C:\program files\common files\system\ado\msado15.dll" rename_namespace("ADOBS") rename("EOF","adoEOF")
using namespace ADOBS;

在项目源文件中加(如果你的FMC工程名字叫ERPsoft)
那么就在ERPsoft.cpp中的 BOOL CERPsoftApp::InitInstance() 上面加如下代码

_ConnectionPtr m_pCon; //ADO连接对象
_RecordsetPtr m_pRs;
_RecordsetPtr m_pRs1;
_CommandPtr m_pCom;


然后添加一个自定义功能函数 IniAdoTwo()

放在
BOOL CERPsoftApp::InitInstance()
{
AfxEnableControlContainer(); //使程序启用ActiveX功能的引用函数 只有将此行代码加入程序主CPP中,才可使用Webbrowser控件切记!
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
m_mainfram = NULL;
IniAdoTwo();
.
.
.
.


void CERPsoftApp::IniAdoTwo()
{

::CoInitialize(NULL); //初始化数据库COM环境 如果不进行初始化数据库COM环境有可能会导致程序无法正常连接到数据库上,切记!切记!
try
{
CString StrMD1,StrMD2,StrMD3,StrMD4,StrMD5;//将数据库进行6层HAX值解密,提高服务器SQL的安全性
CString temp;
char filepath[MAX_PATH];
GetModuleFileName(NULL,filepath,MAX_PATH);
temp = theApp.ExtractFilePath(filepath);//获取可执行文件的路径

CString strAdoConn;
//AfxMessageBox(temp);
char temp1[2048];
CString DATADBO;
GetPrivateProfileString("DatabaseConfig","Server","",temp1,100,temp+"ErpConfigData\\TYErpLogin.ini");
strserver = (TCHAR *)temp1;
GetPrivateProfileString("DatabaseConfig","Database","",temp1,100,temp+"ErpConfigData\\TYErpLogin.ini");
strdbName = temp1;
GetPrivateProfileString("DatabaseConfig","User","",temp1,2048,temp+"ErpConfigData\\TYErpLogin.ini");
//对数据字符串进行6层HAX值解密操作 提高SQL数据库的安全性
DATADBO=DecryptX(temp1,521888);//解密字符串函数 第1层解密
StrMD1=DecryptX(DATADBO,995852);//解密字符串函数 第2层解密
StrMD2=DecryptX(StrMD1,958752);//解密字符串函数 第3层解密
StrMD3=DecryptX(StrMD2,264567);//解密字符串函数 第4层解密
StrMD4=DecryptX(StrMD3,314159);//解密字符串函数 第5层解密
StrMD5=DecryptX(StrMD4,171218);//解密字符串函数 第6层解密
strUser = StrMD5;
GetPrivateProfileString("DatabaseConfig","PWD","",temp1,2048,temp+"ErpConfigData\\TYErpLogin.ini");
//对数据字符串进行6层HAX值解密操作 提高SQL数据库的安全性
DATADBO=DecryptX(temp1,521888);//解密字符串函数 第1层解密
StrMD1=DecryptX(DATADBO,995852);//解密字符串函数 第2层解密
StrMD2=DecryptX(StrMD1,958752);//解密字符串函数 第3层解密
StrMD3=DecryptX(StrMD2,264567);//解密字符串函数 第4层解密
StrMD4=DecryptX(StrMD3,314159);//解密字符串函数 第5层解密
StrMD5=DecryptX(StrMD4,171218);//解密字符串函数 第6层解密
strPassword = StrMD5;
//AfxMessageBox(temp+"ErpConfigData\\TYErpLogin.ini\n【信息交互端连接配置】"+temp);
strAdoConn.Format("driver={SQL Server};SERVER=%s;UID=%s;PWD=%s;DATABASE=%s",
strserver, strUser, strPassword, strdbName);
m_pConX.CreateInstance(_uuidof(Connection));
m_pConX->ConnectionString = (_bstr_t)strAdoConn;
m_pConX->ConnectionTimeout = 3;//连接超时时间
//m_pConX->Open("","","",NULL);//adConnectUnspecified
m_pConX->Open("","","",adConnectUnspecified);//adConnectUnspecified
m_pComX.CreateInstance("ADODB.Command");
m_pRsX.CreateInstance(_uuidof(Recordset));
m_pRsX1.CreateInstance(_uuidof(Recordset));
}
catch(...)
{
AfxMessageBox("SERVER Connect Adortive");
MessageBox(0,"请检查(服务器配置设置)参数是否正确!", "服务器(联接失败!)",MB_OK);
return;
}
}


你再调试下就行了
zgl7903 2018-11-21
  • 打赏
  • 举报
回复
SetDataSource ?


Dreamer558 2018-11-21
  • 打赏
  • 举报
回复
引用 1 楼 zgl7903 的回复:

这个问题解决了,可是那个横着数第二个对话框的问题没解决,大佬你知道吗

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧