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

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

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

Dim OraDB As ADODB.Connection
Public Sub OpenOraDB()
    On Error GoTo ToExit
    OraDB_Open = False
    Set OraDB = New ADODB.Connection
    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"
    OraDB.CursorLocation = adUseServer
   
    OraDB.Open ConnectionString
    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
Private Sub Command1_Click()

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

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

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

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


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/asftrhgjhkjlkttttttt/archive/2010/11/22/6027393.aspx

  • 1
    点赞
  • 0
    评论
  • 1
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值