Solved

opening a oracle database through vb.net

Posted on 2014-03-26
3
1,507 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 36

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 76

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now