vb.net oracle 更新数据库,vb.net連接Oracle数据库

本文档详细介绍了如何安装和配置Oracle客户端,包括设置数据库连接字符串、打开和关闭数据库连接,以及通过CMD验证安装成功的步骤。同时,给出了listener.ora、sqlnet.ora和tnsnames.ora三个关键配置文件的内容示例。
摘要由CSDN通过智能技术生成

Imports Oracle.DataAccess.Client '導入命名空間

Public Class Form1

Dim Sql As String

Public SqlTP As OracleConnection = New OracleConnection("Password= ""密碼"";Persist Security Info=True;User ID=帳號;Data Source=資料庫")

Public CmdTP As New OracleCommand

Public drTP As OracleDataReader

Public Sub OpenTP()'打开Oracle連線

If SqlTP.State = ConnectionState.Closed Then

SqlTP.Open()

End If

CmdTP.CommandText = Sql

CmdTP.CommandType = CommandType.Text

CmdTP.Connection = SqlTP

drTP = CmdTP.ExecuteReader()

End Sub

Public Sub CloseTP()'关闭Oracle連線

drTP.Close()

If SqlTP.State = ConnectionState.Open Then

SqlTP.Dispose()

End If

End Sub

Private Sub A1()

Dim i, n As Integer

Dim TP0 As String

Sql = ("SELECT COUNT(*) FROM SH01.OGA_FILE")

OpenTP()

drTP.Read()

n = drTP.Item(0)'筆數

CloseTP()

Sql = ("SELECT SH01.OGA_FILE.OGA02  FROM SH01.OGA_FILE")

OpenTP()

For i = 1 To n

drTP.Read()'下一筆

TP0 = drTP.Item(0)'內容

Next

CloseTP()

End Sub

End Class

安装oracle客戶端

4eadbc76e8b808da93242f808cb36d76.png

这里点“下一步”

4b5ce164f66fd0305afa112a2030d795.png

这里点“下一步”

44cb28a6c5b659b0e0c480a5e9c1edfa.png

选择“管理员”,再点“下一步”

e30dbdb9ec4223e4d1d72be54e54811e.png

记住这里的路径,下面要用到;再点“下一步”

68df53ead40483196f3c36964ffd0626.png

这里点“下一步”继续

9c1be2904d91e10ec767375994079576.png

这里点“安装”继续

30f33c5b4dafdc7316630d0a761644a0.png

安装进行中……

fec6f2b59848e6032e39f60985893415.png

选择“执行典型配置”再点“下一步”

69d533fcddd633954b34fc7ecf0bd4fb.png

这里点“下一步”继续

e7a3f6f2d99257dd625043fa1ab769f1.png

点击“完成”完成安装,出来后退出安装结束。

配置

listener.ora

sqlnet.ora

tnsnames.ora

三個文件

從安裝位置如D:\oracle\product\10.2.0\client_1\NETWORK\ADMIN打開

listener.ora

內容如下

# listener.ora Network Configuration File: D:\oracle\network\admin\listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = /u2/oracle/10g)

(PROGRAM = extproc)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.5)(PORT = 1521))

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

)

sqlnet.ora內容如下

# This file is actually generated by netca. But if customers choose to

# install "Software Only", this file wont exist and without the native

# authentication, they will not be able to connect to the database on NT.

NAMES.DIRECTORY_PATH= (TNSNAMES)

tnsnames.ora內容如下

# tnsnames.ora Network Configuration File: D:\oracle\network\admin\tnsnames.ora

# Generated by Oracle configuration tools.

TOPTEST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.5)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = toptest)

)

)

TOPSTD =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.5)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = topstd)

)

)

TOPPROD =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.9)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = topprod)

)

)

EXTPROC_CONNECTION_DATA =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

(CONNECT_DATA =

(SID = PLSExtProc)

(PRESENTATION = RO)

)

)

运行CMD――>执行Tnsping 資料庫名稱  检查是否安装成功。

3ad926e1bfb488e550289c346a8b3e5c.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值