Solved

opening a oracle database through vb.net

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

920 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

14 Experts available now in Live!

Get 1:1 Help Now