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