当前位置 : 主页 > 网络编程 > net编程 >

VB.NET 通过引用Oracle.DataAccess.dll连接oracle数据库,无需下载oracle客户端

来源:互联网 收集:自由互联 发布时间:2023-09-06
1.首先从oracle官网上下载一个 Oracle Data Access Components (ODAC) and NuGet,解压找到Oracle.ManagedDataAccess.dll文件,Oracle.ManagedDataAccess.dll存放在 ODP.NET_Managed_ODAC122cR1\​​odp.net​​\managed\common目录

1.首先从oracle官网上下载一个Oracle Data Access Components (ODAC) and NuGet,解压找到Oracle.ManagedDataAccess.dll文件,Oracle.ManagedDataAccess.dll存放在ODP.NET_Managed_ODAC122cR1\​​odp.net​​\managed\common目录下

2.打开VSCODE,工具栏上找到项目--添加引用--选择common目录下的Oracle.ManagedDataAccess.dll--完成

3.把从oracle数据中读取到的数据显示在datagridview控件上

​Imports System

Imports System.Data

Imports System.Collections.Generic

Imports System.Linq

Imports System.Text

Imports System.Threading.Tasks

Imports Oracle.ManagedDataAccess.Client

Imports Microsoft.Win32.SafeHandles

Imports System.Windows.Forms.VisualStyles.VisualStyleElement

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim strConn = "Data Source=192.168.1.13/topprd;User ID=dsdata;Password=dsdata"

Dim dbcmd As OracleCommand

Dim dt = New DataTable("ds")

Dim dbConnection As OracleConnection

dbConnection = New OracleConnection(strConn)

dbConnection.Open()

dbcmd = dbConnection.CreateCommand

dbcmd.CommandText = "select * from IMAAL_T where IMAAL002='zh_CN' AND IMAALENT=66 ORDER BY IMAAL001"

Dim da As OracleDataAdapter = New OracleDataAdapter(dbcmd)

da.Fill(dt)

DataGridView1.DataSource = dt '把dt的值赋值给DataGridview1控件

end sub

END CLASS




【文章转自高防服务器 http://www.558idc.com 复制请保留原URL】
上一篇:vue.config.js(大力子)
下一篇:没有了
网友评论