VB连接ORACLE数据库
2007-06-02 16:04:39 来源:WEB开发网核心提示:'打开数据库 Public Sub OpenOraDB() On Error GoTo ToExit OraDB_Open = False Set OraDB = New ADODB.Connection OraConstr = "Provider=OraOLEDB.Oracle.1;Password
'打开数据库
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 & ";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
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 & ";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
- ››oracle 恢复误删除的表和误更新的表
- ››Oracle分页查询排序数据重复问题
- ››Oracle创建dblink报错:ORA-01017、ORA-02063解决
- ››Oracle 提高SQL执行效率的方法
- ››Oracle 动态查询,EXECUTE IMMEDIATE select into...
- ››Oracle 11g必须开启的服务及服务详细介绍
- ››oracle性能34条优化技巧
- ››oracle数据库生成随机数的函数
- ››Oracle 数据库表空间容量调整脚本
- ››oracle单库彻底删除干净的方法
- ››Oracle创建表空间、创建用户以及授权、查看权限
- ››oracle 中 UPDATE nowait 的使用方法
更多精彩
赞助商链接