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

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

hi shark_1,

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.