Home > Software engineering >  Vc 6.0 SQL SERVER2008 MFC connection
Vc 6.0 SQL SERVER2008 MFC connection

Time:09-21


Having problems is the database permission?





Can't find this function is how to return a responsibility?



CodePudding user response:

SetDataSource?


CodePudding user response:

reference 1st floor zgl7903 response:

The problem solved, but the cross for the second dialog box problem didn't solve, bosses, you know

CodePudding user response:

Can't see the error code, the error message baidu baidu




CodePudding user response:

I'll give you stick a complete code directly!
Add the following code stdafx. H
# import "C: \ program files \ common files \ system \ ado \ msado15 DLL" rename_namespace (" ADOBS ") rename (" EOF ", "adoEOF")
Using the namespace ADOBS;

In the project source files to add name (if your FMC engineering ERPsoft)
Then in ERPsoft. CPP the BOOL CERPsoftApp: : InitInstance () add the following code above

_ConnectionPtr m_pCon;//ADO connection object
_RecordsetPtr m_pRs;
_RecordsetPtr m_pRs1;
_CommandPtr m_pCom;


Then add a custom functions IniAdoTwo ()

In a
BOOL CERPsoftApp: : InitInstance ()
{
AfxEnableControlContainer ();//make the program to enable the ActiveX function reference function only to add this line to the CPP program, just can use Webbrowser control remember!
//Standard initialization
//If you are not using these features and wish to reduce the size
//of your final executable, you should remove the from the following
//the specific initialization routines you do not need.

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


Void CERPsoftApp: : IniAdoTwo ()
{

: : CoInitialize (NULL);//initialize database COM COM if not initialize database environment is likely to cause the program can't normal to connect to the database, remember! Remember that!
Try
{
Cstrings StrMD1 StrMD2, StrMD3 StrMD4, StrMD5;//decrypt the database for 6 layer HAX value, improve the security of the SQL server
Cstrings temp.
Char filepath [MAX_PATH];
GetModuleFileName (NULL, filepath MAX_PATH);
Temp=theApp. ExtractFilePath (filepath);//get the path of the executable file

Cstrings strAdoConn;
//AfxMessageBox (temp);
Char temp1 [2048].
Cstrings DATADBO;
GetPrivateProfileString (" DatabaseConfig "and" Server ", "", temp1, 100, temp +" ErpConfigData \ \ TYErpLogin ini ");
Strserver=temp1 (TCHAR *);
GetPrivateProfileString (" DatabaseConfig ", "Database", "", temp1, 100, temp +" ErpConfigData \ \ TYErpLogin ini ");
StrdbName=temp1;
GetPrivateProfileString (" DatabaseConfig ", "User", "", temp1, 2048, temp +" ErpConfigData \ \ TYErpLogin ini ");
//to 6 layer HAX data string value decryption operation to improve the safety of SQL database
DATADBO=DecryptX (temp1, 521888);//decrypt decrypt the string function layer 1
StrMD1=DecryptX (DATADBO, 995852);//decrypt the string function layer 2 decryption
StrMD2=DecryptX (StrMD1, 958752);//decrypt the string function layer 3 decryption
StrMD3=DecryptX (StrMD2, 264567);//decrypt the string function layer 4 decryption
StrMD4=DecryptX (StrMD3, 314159);//decrypt the string function layer 5 decryption
StrMD5=DecryptX (StrMD4, 171218);//decrypt the string function layer 6 decryption
StrUser=StrMD5;
GetPrivateProfileString (" DatabaseConfig ", "PWD", "", temp1, 2048, temp +" ErpConfigData \ \ TYErpLogin ini ");
//to 6 layer HAX data string value decryption operation to improve the safety of SQL database
DATADBO=DecryptX (temp1, 521888);//decrypt decrypt the string function layer 1
StrMD1=DecryptX (DATADBO, 995852);//decrypt the string function layer 2 decryption
StrMD2=DecryptX (StrMD1, 958752);//decrypt the string function layer 3 decryption
StrMD3=DecryptX (StrMD2, 264567);//decrypt the string function layer 4 decryption
StrMD4=DecryptX (StrMD3, 314159);//decrypt the string function layer 5 decryption
StrMD5=DecryptX (StrMD4, 171218);//decrypt the string function layer 6 decryption
StrPassword=StrMD5;
//AfxMessageBox (temp + "ErpConfigData \ \ TYErpLogin ini \ n [information interaction terminal connection configuration]" + temp);
StrAdoConn. The Format (" driver={SQL Server}; SERVER=% s. UID=% s. The PWD=% s. The DATABASE=% s ",
Strserver strUser, strPassword strdbName);
M_pConX. CreateInstance (_uuidof (Connection));
M_pConX - & gt; The ConnectionString=(_bstr_t) strAdoConn;
M_pConX - & gt; ConnectionTimeout=3;//connection timeout
//m_pConX - & gt; Open (" ", ""," ", NULL);//adConnectUnspecified
M_pConX - & gt; Open (" ", ""," ", adConnectUnspecified);//adConnectUnspecified
Mand m_pComX. CreateInstance (" ADODB.Com ");
M_pRsX. CreateInstance (_uuidof (you));
M_pRsX1. CreateInstance (_uuidof (you));
}
The catch (... )
{
AfxMessageBox (" Adortive SERVER Connect ");
MessageBox (0, "please check (server configuration Settings) parameter is correct!" , "server (a join failure! ", MB_OK);
return;
}
}


You again under debugging

CodePudding user response:

Give you recommend me to write a complete example of vc + + SqlSERVER2008R2 database operation FMC connection
You slowly in the past research studies under the

Black men's clothing ERP production management software source code (black men 11 super bleeding! The big jump off a building! Big bang gave the general programming enthusiasts of a complete set of source code!)
https://blog.csdn.net/blackangelboy/article/details/84346296

To give you a I recently to write the source code of even the point of the mouse!
https://blog.csdn.net/blackangelboy/article/details/84343862

CodePudding user response:

Both inside the program source code I wrote almost have the features you have a full set of SQL database operations!
Connection, add and delete sorting summary analysis logic operations, etc., etc.
Black men's clothing ERP production management software source code
https://blog.csdn.net/blackangelboy/article/details/84346296
Then send you a I recently to write the source code of even the point of the mouse!
null
  • Related