Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

opening a oracle database through vb.net

Posted on 2014-03-26
3
Medium Priority
?
1,572 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 38

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 1000 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 1000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

719 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