VC Oracle development portal Author: Yan Yin Chuan
The Oracle database is widely praised in its excellent performance. But the Oracle client is not easy to connect to the database as SQL Server. First, we must put an ORACLEL OLEDB communication software to the client, which can be obtained from the following address:
ftp://yblshenzhen.8800.org/oraoledb.exe www.roacle.com
Only this software is installed, the client can communicate with the Oracle server. Why SQL Server can connect directly to the database, because Microsoft integrates "SQL Server's communication software" to Windows. Pack communication software, we want to configure to connect to the server correctly. Open NET Configuration Assistance, the following screen appears: Figure 1 In "Listening Program Configuration" and "Name Method Configuration" two guarantees, pay attention to the local network service name configuration, select the local network service name configuration, keep default to configuration This step is step by step: Figure 2 Note the name of this server is the SID of the Oracle database, I am Mike here. Then the next step is to select the protocol, generally TCP, the next step is to enter the host name, for the server's IP or NetBIOS NAME. Figure 3 To ensure that you can ping the host name. Figure 4 Next is the test, it is best to test success, if it is not successful, start from three aspects:
Check if the Oracle server is started; check if the SID is correct; if the network between the host is connected; the username and password are correct, the initial is Scott / Tiger;
Now use VC to create a dialog-based project. We use the ADO to connect to the database, join in stdafx.h:
#import "C: / Program files / compon files / system / ado / msado15.dll" no_namespace rename ("EOF", "AdoEOF")
Add:
try {m_pConnection.CreateInstance (__ uuidof (Connection)); m_pConnection-> Open ( "Provider = MSDAORA.1; Data Source = mike;", "scott", "tiger", adModeUnknown);} catch (_com_error e) {AfxMessageBox (e.ErrorMessage ());} m_pRecordset.CreateInstance (__ uuidof (Recordset)); m_pRecordset-> open (( "select * from yourtables", m_pConnection.GetInterfacePtr (), adOpenDynamic, adLockOptimistic, adCmdText)); and the remainder Common ADO database operation is ...