0

Here is my environment:

64-bit Operating System, x64 based processor Windows 10 Enterprise Visual Studio 2010 Oracle Client 64 11gR2 ODAC 64k ODAC 32k

The issue is I can't get Visual Studio 2010 connecting to Oracle 11g Database.

Tried Oracle.DataAccess.DLL from Oracle Client 64 11gR2, ODAC 64k and ODAC32k, no success.

Also tried to set .NET framework to 4 and 2, no luck.

Also tried System.Data.OracleClient, it complains abount 32bit and 64bit conflict

Any help would be appreciated.

Thanks

Imports Oracle.DataAccess.Client Partial Class _Default Inherits System.Web.UI.Page

Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
    Dim oradb As String = "Data Source=CustomerDB;User ID=userid;Password=password"
    Dim conn As New Oracle.DataAccess.Client.OracleConnection(oradb)
    Response.Write(conn.Database.ToString())
    Response.Write(conn.State.ToString)
    conn.Open()
    Dim sql As String = "select name from customer where CustID=1"
    Dim cmd As New Oracle.DataAccess.Client.OracleCommand(sql, conn)
    Dim dr As Oracle.DataAccess.Client.OracleDataReader = cmd.ExecuteReader()
    dr.Read()
    Response.Write(dr.Item("name"))
    conn.Close()
    conn.Dispose()
End Sub

End Class

kkazi
  • 1
  • 2

1 Answers1

0

Visual Studio itself is not 64-bit. You will need to install the 32-bit components to be able to connect Visual Studio to Oracle.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • ODAC 32 has been installed yet, accordingly reference has been added in the project yet no luck. – kkazi Jun 28 '16 at 05:31
  • @kkazi Oh so it's *your* program that cannot connect. Well we cannot say, you will need to post actual code and an error message. – nvoigt Jun 28 '16 at 09:57
  • Thanks @nvoigt for looking into the issue.
    Okay, I have now installed Oracle Client 32 bit as well and copied the Oracle.DataAccess.dll into the Bin folder, from where I have added the file as reference in the project.
    And still receiving this error in the 3rd line of the code _conn.Open()_
    – kkazi Jun 29 '16 at 02:29
  • System.NullReferenceException was unhandled by user code HResult=-2147467261 Message=Object reference not set to an instance of an object. Source=Oracle.DataAccess StackTrace: at Oracle.DataAccess.Client.OracleConnection.Open() at _Default.Button1_Click(Object sender, EventArgs e) in C:\inetpub\OracleTest1\Default.aspx.vb:line 8 – kkazi Jun 29 '16 at 02:31
  • Imports Oracle.DataAccess.Client Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click Dim oradb As String = "Data Source=CustomerDB;User ID=userid;Password=password" Dim conn As New Oracle.DataAccess.Client.OracleConnection(oradb) conn.Open() – kkazi Jun 29 '16 at 02:33
  • Please don't post your code as comments. Please use the edit option in your question to put in your code there. – nvoigt Jun 29 '16 at 05:35