How VB Connects Oracle database VB to Oracle access method

Source: Internet
Author: User
Tags database join error handling goto join odbc ole oracle database

Generally speaking, we do this through ODBC to access the remote backend database. However, ODBC has a fatal drawback--slow speed. In fact, for Oracle databases, in addition to ODBC, we can use the OLE object (Oracle Objects for OLE) provided by Oracle itself to quickly access the database.

In Oracle V8, Oracle Objects for OLE (hereinafter referred to as OO) provides a set of simple, database-connected communication accesses for common development tools, supporting a variety of development environments that support VB custom controls or OLE Automation (OLE Automation). Oo is made up of three main parts:

L Oracle Object Server (Oracle)

• Oracle Data access control

L C + + class libraries (the Oracle Objects for OLE C + + class library)

Oo mainly includes objects and uses:

Oraclient defines the work domain and manages the session set.

Orasession manages the set of database objects and provides shared connectivity and transaction control.

Oraconnection the connection established between Oracle data.

Oradatabase a "virtual" login to the Oracle database.

Oraparamarray parameter group.

Oraparameter the relevant variables that are bound in an SQL statement or Pl/sql block.

Oradynaset the records obtained by using the SELECT statement.

Orasqlstmt a predefined, separate SQL statement.

Orafield the Columns (column) in the Oradynaset object.

Private Sub Command_click ()

Ls_server = "Baoprog"

' Join local Oracle Database

Ls_username = "System"

' User name is System

Ls_password = "Manager"

' Password is manager

' Create a Orasession object

Set orasession = CreateObject ("Oracleinprocserver.xorasession")

' Error handling

On Error GoTo Connect_err:

' Url:http://www.bianceng.cn/programming/vb/201410/45788.htm

' Create a Oradatabase object to join to the Oracle database

Set oradatabase = Orasession.dbopendatabase (ls_server, Ls_username + "/" + Ls_password, 0&)

On Error GoTo 0

Exit Sub

Connect_err:

If InStr (Orasession.lastservererrtext, "ORA-01017") Then

MsgBox "Invalid username and password, database join unsuccessful!", vbOKOnly + vbcritical, "prompt info"

Else

MsgBox the database join was unsuccessful! Please see the following error message: "+ Chr + orasession.lastservererrtext, vbOKOnly + vbcritical," prompt info "

End If

End Sub

Related Article

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.