回覆列表
  • 1 # 敘永萬學寬

    Public Sub OpenOraDB()

    On Error GoTo ToExit

    OraDB_Open = False

    Set OraDB = New ADODB.Connection

    OraConstr = "Provider=OraOLEDB.Oracle.1;Password=" & strOraPWD & ";User;Data Source=" & OraDBNetName & ";Persist Security Info=False"

    OraDB.CursorLocation = adUseServer

    OraDB.Open OraConstr

    OraDB_Open = True

    Exit Sub

    ToExit:

    "MsgBox "連線資料庫伺服器錯誤,您可以在網路正常後繼續使用。",vbInformation , "錯誤資訊"

    OraDB_Open = False

    End Sub

    "關閉資料庫

    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

    "開啟資料集,寫入資料

    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

    "關閉資料集

    OraRS.Close

    Set OraRS = Nothing

    http://topic.csdn.net/t/20050508/19/3990155.html

  • 中秋節和大豐收的關聯?
  • 酥帶魚用高壓鍋怎麼做?