vb无客户端连接oracle数据库的解决办法

前端之家收集整理的这篇文章主要介绍了vb无客户端连接oracle数据库的解决办法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

油田普遍用的是oracle数据库,我们在给油田用户编制程序的时候如果用VB编码,程序编好后,还需要在用户的机器上安装一个oracle数据库客户端,以便能连接到oracle服务器。这无疑会增加用户不少工作量,降低软件的友好性。经过网上搜索,找到一些替代办法,方法如下:

一、创建VB工程,引用两个dll,一个是oraoledb 1.0 type library;另一个是MS ado 2.8 library。程序代码如下:

Dim OraDB As ADODB.Connection@H_404_10@Public Sub OpenOraDB()@H_404_10@ On Error GoTo ToExit@H_404_10@ OraDB_Open = False@H_404_10@ Set OraDB = New ADODB.Connection@H_404_10@ ConnectionString = "Provider=OraOLEDB.Oracle;Password=cygck;User ID=cygck;Data Source=""(DESCRIPTION =(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=121.251.249.191)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ora9i)))"";Persist Security Info=True"@H_404_10@ OraDB.CursorLocation = adUseServer@H_404_10@ @H_404_10@ OraDB.Open ConnectionString@H_404_10@ OraDB_Open = True@H_404_10@ @H_404_10@ Exit Sub@H_404_10@ToExit:@H_404_10@ MsgBox "连接数据库服务器错误,您可以在网络正常后继续使用。",vbInformation,"错误信息"@H_404_10@ OraDB_Open = False@H_404_10@End Sub

'关闭数据库

Public Sub CloSEOraDB()@H_404_10@ If OraDB_Open = True Then@H_404_10@ If (OraDB.State = adStateOpen) Then@H_404_10@ OraDB.Close@H_404_10@ Set OraDB = Nothing@H_404_10@ OraDB_Open = False@H_404_10@ End If@H_404_10@ End If@H_404_10@End Sub@H_404_10@Private Sub Command1_Click()

'打开数据集,写入数据@H_404_10@OpenOraDB@H_404_10@Set OraRS = New ADODB.Recordset@H_404_10@OraRS.ActiveConnection = OraDB@H_404_10@OraRS.CursorLocation = adUseServer@H_404_10@OraRS.LockType = adLockBatchOptimistic@H_404_10@strOraRS = "select count(*) from daa01"@H_404_10@'OraRS.Open strOraRS,OraDB,adOpenStatic,adLockOptimistic@H_404_10@Set OraRS = OraDB.Execute(strOraRS)@H_404_10@MsgBox (OraRS(0))@H_404_10@'关闭数据集@H_404_10@OraRS.Close@H_404_10@Set OraRS = Nothing@H_404_10@End Sub

二,打包。采用Setup Factory 7.0打包。将以下文件打包。其中oraoledb.dll在文件属性-高级中选择“注册类型库”,保证在安装后能够regsvr32该文件

D:/项目/无客户端连接oracle/ora9 的目录

2009-08-25 16:06 <DIR> .@H_404_10@2009-08-25 16:06 <DIR> ..@H_404_10@2001-09-12 10:52 1,329,424 oraclient9.dll@H_404_10@2001-09-12 10:52 497,936 oracommon9.dll@H_404_10@2001-08-09 12:09 603,920 ORACORE9.DLL@H_404_10@2001-09-11 22:29 1,630,992 orageneric9.dll@H_404_10@2001-08-17 09:31 123,664 oraldapclnt9.dll@H_404_10@2001-09-10 17:23 740,112 ORAN9.DLL@H_404_10@2001-08-15 12:00 5,392 ORANCDS9.DLL@H_404_10@2001-09-10 17:23 58,640 orancrypt9.dll@H_404_10@2001-09-10 17:23 7,440 oranhost9.dll@H_404_10@2001-09-09 21:09 162,064 ORANL9.DLL@H_404_10@2001-08-22 12:23 50,960 oranldap9.dll@H_404_10@2001-08-17 10:26 412,944 ORANLS9.DLL@H_404_10@2001-08-06 20:19 10,512 ORANMS.DLL@H_404_10@2001-08-06 20:19 50,960 ORANMSP.DLL@H_404_10@2001-08-22 12:19 546,576 orannzsbb9.dll@H_404_10@2001-09-10 17:23 5,904 oranoname9.dll@H_404_10@2001-09-10 17:23 211,216 Oranro9.dll@H_404_10@2001-09-10 17:23 7,952 ORANTNS9.DLL@H_404_10@2001-08-17 19:39 385,024 OraOLEDB.dll@H_404_10@2001-08-17 19:39 118,784 OraOLEDBgmr.dll@H_404_10@2001-08-17 19:39 32,768 OraOLEDBpus.dll@H_404_10@2001-08-17 19:39 126,976 OraOLEDBrst.dll@H_404_10@2001-08-17 19:39 24,576 OraOLEDButl.dll@H_404_10@2001-08-17 19:39 24,576 OraOLEDBzhs.dll@H_404_10@2001-08-14 20:20 2,102,032 ORAPLS9.DLL@H_404_10@2001-06-20 18:00 13,072 ORASLAX9.DLL@H_404_10@2001-08-17 10:26 48,400 ORASNLS9.DLL@H_404_10@2001-08-14 12:28 456,464 ORAsql9.DLL@H_404_10@2001-08-08 07:31 248,592 oratrace9.dll@H_404_10@2001-08-17 10:26 43,280 ORAUNLS9.DLL@H_404_10@2001-08-14 21:19 5,904 ORAVSN9.DLL@H_404_10@2001-09-12 10:52 7,440 Orawtc9.dll@H_404_10@ 32 个文件 10,094,496 字节@H_404_10@ 2 个目录 5,160,677,376 可用字节

三,以上ORA文件获取

http://tml.cn/soft/OCI/dll.rar

下载该文件后安装,在windows/system32中有以上ora文件

原文链接:

http://hi.baidu.com/upczhou/blog/item/8bda0ed94dae2be339012fbb.html

原文链接:https://www.f2er.com/vb/261606.html

猜你在找的VB相关文章