
難道是資料庫權限有問題??

找不到這個函式是怎么回事?
uj5u.com熱心網友回復:
SetDataSource ?uj5u.com熱心網友回復:
這個問題解決了,可是那個橫著數第二個對話框的問題沒解決,大佬你知道嗎
uj5u.com熱心網友回復:
看不到錯誤代碼啊, 把錯誤資訊 百度 百度uj5u.com熱心網友回復:
我來直接給你貼完整代碼!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;
}
}
你再除錯下就行了
uj5u.com熱心網友回復:
給你推薦一個我寫的完整的VC++fmc連接操作SqlSERVER2008R2資料庫的例子你下過去慢慢研究研究就行了
黑男服裝ERP生產管理軟體源代碼(黑男雙十一超級大出血!大跳樓!大爆炸贈送給廣大編程愛好者的整套源代碼!)
https://blog.csdn.net/blackangelboy/article/details/84346296
給大家贈送一個我最近寫的滑鼠連點器的源代碼!
https://blog.csdn.net/blackangelboy/article/details/84343862
uj5u.com熱心網友回復:
這兩個我寫的程式源代碼里面幾乎有你所要的全套SQL資料庫的操作!連接、增刪改查 排序 匯總 分析 邏輯運算 等等等等
黑男服裝ERP生產管理軟體源代碼
https://blog.csdn.net/blackangelboy/article/details/84346296
再送你一個我最近寫的滑鼠連點器的源代碼!
https://blog.csdn.net/blackangelboy/article/details/84343862
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/59535.html
標籤:數據庫
