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}; " & _
         "(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)
        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()
        TextBox1.Text = dr.Item("asset_id")
    End Sub
End Class
Re: able to connect with SQL Developer but not with VB.net 80 80

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

Re: able to connect with SQL Developer but not with VB.net 80 80

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 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.