Hello All,

I am fairly new to Vb.net. I have experience in MS Access and VBA. I am trying to connect a remote Oracle Database through vb.net but getting the below error. But, the same Oracle database connecting with the help of SQL Developer. Can any one please help me?

Imports System.Data
Imports Oracle.DataAccess.Client ' ODP.NET Oracle managed provider
Imports Oracle.DataAccess.Types


Public Class Form1

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

        Dim oradb As String
        oradb = "Driver={Microsoft ODBC for Oracle}; " & _
         "CONNECTSTRING=(DESCRIPTION=" & _
         "(ADDRESS=(PROTOCOL=TCP)(HOST=myhostname)(PORT=1521))" & _
         "(CONNECT_DATA=(SERVICE_NAME=myservice name))); (INSTANCE_NAME=myinstance); uid=user;pwd=pass;"

        Dim conn As New OracleConnection(oradb)
        conn.Open()
        Dim cmd As New OracleCommand
        cmd.Connection = conn
        cmd.CommandText = "select asset_id from trend.asset_classification"
        cmd.CommandType = CommandType.Text
        Dim dr As OracleDataReader = cmd.ExecuteReader()
        dr.Read()
        TextBox1.Text = dr.Item("asset_id")
        conn.Dispose()
    End Sub
End Class
Attachments error.jpg 20.87 KB

Did you instal oracle odbc driver ? If so make reference to your project and connect it through your connection object.

Edited 8 Months Ago by Shark_1

hi shark_1,

Yes, I have installed Oracle ODBC driver, I guess, I have already reference in my project.

This article has been dead for over six months. Start a new discussion instead.