Home > Software engineering >  Vs2010 Oracle11g database connection
Vs2010 Oracle11g database connection

Time:10-08

Operating environment: the server is installed on a virtual machine (Windows 7 64 - bit) client installed on this machine (Windows 7 64 - bit), including server and client are selected Oracle11g64, the server is configured with listeners, client configuration service naming, VS2010 MFC to write a client to connect server locally small programs, data in the database connection part has been submitted to the memory is unusual, the connection string and user password is correct, and in the local SQL/DEVELOPE can be the connection is successful,

Cstrings lpszConnect;
Cstrings userId.
Cstrings Password;
UserId=_T (topo "");
Password=_T (" Oracle11g ");

LpszConnect=_T (" Provider=OraOLEDB. Oracle. 1; Persist Security Info=False; Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(TCP) PROTOCOL=(HOST=192.168.1.107) (1521) PORT=)) (CONNECT_DATA=https://bbs.csdn.net/topics/(SERVICE_NAME=former))) ");
If (FAILED (: : CoInitialize (NULL)))
{
AfxMessageBox (_T (" ADO Init failed "));
return false;
}
Try
{
M_pConnection. CreateInstance (__uuidof (Connection));
M_pConnection - & gt; Open (_bstr_t (lpszConnect), _bstr_t (userId), _bstr_t (Password), adModeUnknown);
}
Catch _com_error * (e)
{
Cstrings err;
Err. The Format (_T (" & lt; Tip: & gt; Connection error! : \ r \ n error message: % s "), e - & gt; ErrorMessage ());
AfxMessageBox (err);
return false;
}

Application submitted to the error is as follows:

CodePudding user response:

Catch _com_error * (e)
Change
Catch _com_error (e)
See if you can catch exceptions and output error information

CodePudding user response:

Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand when double click on the next line, until we can read ,

CodePudding user response:

reference 1st floor CharlesSimonyi response:
catch _com_error * (e)
Change
Catch _com_error (e)
See if you can catch exceptions and output error message


Changed after the great god, I really can catch mistakes, is to open a connection error, but haven't connection is successful in several kinds of connection string, use new UDL file copying the connection string, still submitted to the connection error, very depressed!

CodePudding user response:

Do you have any initial com

CodePudding user response:

AfxOleInit do

LpszConnect content right, didn't see you

CodePudding user response:

Our project is open oracleo:
 
StrConnection +="provider=oraoledb. Oracle; Data source="+ strDataSource +"; OLE DB Services=4 ";
Hr=m_pConnection - & gt; Open (_bstr_t (m_strConnection), _bstr_t (lpstrUserID), _bstr_t (lpstrPassword), NULL);

You might as well try,
In addition, with the third party client, such as PLSQL connect right, or reinstall the 32-bit test,
In my impression, we project met 64 connections are not problems, instead of 32 bit to go,

CodePudding user response:

In a 64 - bit Windows:
64 exe and DLL in the directory c: \ Windows \ sys tem32 directory.
32 bit exe and DLL in the directory c: \ Windows \ sys wow64 directory.
So pay attention to:
In win64 system registered under 32-bit ocx DLL to 32 ocx or copy the DLL to the c: \ Windows \ syswow64 \ directory,
And registered to c: \ Windows \ syswow64 \ regsvr32 XXXXXXX ocx or DLL
Under win64 a system set up 32-bit programs use a database alias to c: \ Windows \ \ syswow64 \ cliconfg exe
Under win64 a system set up a 32-bit application system DSN to c: \ Windows \ \ syswow64 \ odbcad32 exe
  • Related