Solved

opening a oracle database through vb.net

Posted on 2014-03-26
3
1,528 Views
Last Modified: 2014-04-01
I am trying to open a oracle database through vb.net but I get the message below.

below is my code

Dim oradb As String = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxxx)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=bibpt1))); User Id=userid;Password=pw;"

        Dim conn As New OracleConnection(oradb)
        conn.Open()

Could not load file or assembly 'Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format
0
Comment
Question by:Anthony Matovu
3 Comments
 
LVL 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 250 total points
ID: 39955856
install oracle client on the machine

the oracle client contains the drivers to access the database via vb.net (or any other programming environment

it also depends on you using the 32-bit or 64-bit
> if you have a 32-bit machine or are using 32-bit software, use the 32-bit

check this item for downloading:
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/database12c-win64-download-1968077.html
Oracle Database 12c Release 1 Client (12.1.0.1.0) for Microsoft Windows (x64 and 32-bit)
0
 
LVL 1

Author Comment

by:Anthony Matovu
ID: 39956695
I have tried to change the code to below  and I get the error

"Attempt to load Oracle client libraries threw BadImageFormatException.  This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed."

Thank you for your help

Dim connectionString As String = "Data Source=ThisOracleServer;Integrated Security=yes;"

        Dim queryString As String = "SELECT served_msisdn_nr FROM BIB_ADHOC.vw_marketing_datamart_monthly"

        Using connection As New OracleConnection(connectionString)
            Dim command As OracleCommand = connection.CreateCommand()
            command.CommandText = queryString
            Try
                connection.Open()
                Dim dataReader As OracleDataReader = _
                 command.ExecuteReader()
                Do While dataReader.Read()
                    Console.WriteLine(vbTab & "{0}" & vbTab & "{1}", _
                     dataReader(0), dataReader(1))
                Loop
                dataReader.Close()

            Catch ex As Exception
                Console.WriteLine(ex.Message)
            End Try
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 250 total points
ID: 39956957
The bit version of the app and of the Oracle driver need to match.

Oracle might be getting confused if you are compiling the app for AnyCPU.

Since it looks like you are playing with the 12c drivers, I suggest you try the new Managed driver.  This new driver does not need an Oracle Client install but has some limitations on supported objects.

I recently started testing it and so far like what I've been seeing.

Download the correct bit version from:
http://www.oracle.com/technetwork/topics/dotnet/downloads/index.html
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question