I am using Visual Studio 2012 (64 bit) and oracle 11g (64 bit). When I go to connect oracle database occurring following 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.
I have spend many times to solve this problem. But did not do that.
Sample Code
using System;
using System.Data;
using System.Data.OracleClient; //Add This
namespace Oracle_database
{
class Program
{
static void Main(string[] args)
{
OracleConnection con = new OracleConnection();
//using connection string attributes to connect to Oracle Database
con.ConnectionString = "User Id=abc;Password=12345;Data Source=ORCL";
con.Open();
DateTime fromDate = DateTime.Now.AddDays(-760);
DateTime toDate = DateTime.Now.AddDays(-760);
string sd = fromDate.Year + fromDate.Month.ToString("00") + fromDate.Day.ToString("00");
string ed = toDate.Year + toDate.Month.ToString("00") + toDate.Day.ToString("00");
var cmd = new OracleCommand();
cmd.CommandText = String.Format("Select E.c_Date, E.c_Time, E.l_UID, E.l_TID from tEnter E where E.c_Date>='{0}' and E.c_Date<='{1}'", sd, ed);
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
OracleDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
if (!reader.HasRows) continue;
if (reader[2].ToString() == "-1") continue;
}
// Close and Dispose OracleConnection object
con.Close();
con.Dispose();
Console.WriteLine("Disconnected");
}
}
}
Could you help me?