How to connect a VC to an oracle database and an SQL Server database

Source: Internet
Author: User

The following describes how VC connects to the oracle database and SQL Server for your reference. If you are interested in connecting to the oracle database, take a look.

Connect VC to oracle Database

 
 
  1. _ ConnectionPtr m_pConn;
  2. CString m_sConn = "Provider = MSDAORA.1; Data Source = sode_192.168.3.9"; // use
  3. Ms Connection Library, sode is SID, 192.168.3.9 is the machine ip Address
  4. M_pConn.CreateInstance ("ADODB. Connection ");
  5. Try
  6. {
  7. HRESULT hr = m_pConn-> Open (_ bstr_t) m_sConn, "sodeUser", "sodePw", adConnectUnspecified );
  8. If (FAILED (hr ))
  9. {
  10. AfxMessageBox ("cannot connect to database source! ");
  11. Return FALSE;
  12. }
  13. }
  14. Catch (_ com_error e)
  15. {
  16. AfxMessageBox ("the database error cannot be opened! ");
  17. Return FALSE;
  18. }

Connect to the SQL Server database using VC

 
 
  1. _ ConnectionPtr m_pConn;
  2. CString m_sConn = "Provider = SQLOLEDB.1; Data Source = 192.168.3.9; Initial
  3. Catalog = sode "; // sode is a database on the database server 192.168.3.9.
  4. M_pConn.CreateInstance ("ADODB. Connection ");
  5. Try
  6. {
  7. HRESULT hr = m_pConn-> Open (_ bstr_t) m_sConn, "sa", "mapper", adConnectUnspecified );
  8. If (FAILED (hr ))
  9. {
  10. AfxMessageBox ("cannot connect to database source! ");
  11. Return FALSE;
  12. }
  13. }
  14. Catch (_ com_error e)
  15. {
  16. AfxMessageBox ("cannot connect to database error! ");
  17. Return FALSE;
  18. }

C # connect to the Oracle database to query data

Instances that use oracle Stored Procedure Paging

Oracle RMAN backup Optimization

Learn about Oracle OS backup

Provides you with an in-depth understanding of how ORACLE runs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.