I am trying to connect to Oracle. I know I am close but missing something. I have attached my code. I am wondering if I am missing and Imports statement?
VB.NET:
Imports System.Data.OleDb
Imports System.Data.SqlClient
Private Sub btnOracleDBConnect_Click(sender As Object, e As EventArgs) Handles btnOracleDBConnect.Click Dim oledbCommand As OleDbCommand
Dim dr As OleDbDataReader
Dim sOracledb As New OleDb.OleDbConnection("PROVIDER=MSDAORA;UserID=user;password=pw;database=db")
'Doesn't work -->"PROVIDER=OraOLEDB.Oracle;UserID=user;password=pw;database=db"
'Doesn't work -->"PROVIDER=MSDAORA;UserID=user;password=pw;database=db"
'Doesn't work -->"PROVIDER=MSDAORA.1;UserID=user;password=pw;database=db"
Dim sSQL As String = "select * from MCO_PROVIDER_COUNTY;" 'Test query to see if it is working.
oledbCommand = New OleDbCommand(sSQL, sOracledb)
Try
sOracledb.Open()
'DataReader can be done in Memory.
dr = oledbCommand.ExecuteReader()
While dr.Read()
'reading from the datareader
MessageBox.Show("County ID: " & dr(0))
MessageBox.Show("County Name: " & dr(1))
'MessageBox.Show("Job" & dr(2))
'MessageBox.Show("Mgr" & dr(3))
'MessageBox.Show("HireDate" & dr(4))
'displaying data from the table
End While
dr.Close()
sOracledb.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub