VB Connection Oracle Database

Source: Internet
Author: User
Tags oracle database
' Open the Database

Public Sub openoradb ()
On Error GoTo Toexit
Oradb_open = False
Set oradb = New ADODB. Connection
Oraconstr = "PROVIDER=ORAOLEDB.ORACLE.1; Password= "& Strorapwd &"; User id= "& Strorauser &";D ata source= "& Oradbnetname &"; Persist Security Info=false "
Oradb.cursorlocation = adUseServer

Oradb.open Oraconstr
Oradb_open = True

Exit Sub
Toexit:
' MsgBox ' connection to the database server error, you can continue to use after the network is normal. ", vbinformation," error message "
Oradb_open = False
End Sub

' Close the database

Public Sub closeoradb ()
If Oradb_open = True Then
If (oradb.state = adStateOpen) Then
Oradb.close
Set oradb = Nothing
Oradb_open = False
End If
End If
End Sub

' Open the dataset, write the data

Set orars = New ADODB. Recordset
Orars.activeconnection = oradb
Orars.cursorlocation = adUseServer
Orars.locktype = adLockBatchOptimistic
Strorars = "SELECT * from" & Oradbtablename
Orars.open Strorars, oradb, adOpenStatic, adLockOptimistic
Orars.addnew
Orars.fields ("PID") = Strorapid
Orars.fields ("pname") = StrName "). Value
Orars.fields ("psex") = Strpsex
Orars.update

' Close Data set

Orars.close
Set Orars = Nothing
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.