Since monday I followed several tutorials to establish connection to my Oracle database.
I downloaded at http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html and launched "install.bat".
In visual studio, in reference section I browsed the directory that I downloaded and found "Oracle.DataAccess.dll" in the following path "\odp.net4\odp.net\bin\4".
When I run my code I get the following error:
External component has thrown an exception
Furthermore I have the following warning :
Warning 1 There is a difference between the project processor architecture being generated "MSIL" and the reference processor architecture "Oracle.DataAccess, Version = 4.121.2.0, Culture = neutral, PublicKeyToken = 89b483f429c47342, processorArchitecture = x86 "," AMD64 ". This difference can lead to runtime problems.
I don't understand this error so I hope you will be able to help me.
Or if you know a better way to connect to a database oracle, I will be interested.
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OraTest oraTest = new OraTest();
oraTest.Connect();
oraTest.Close();
MessageBox.Show("Connecté");
}
}
}
using Oracle.DataAccess.Client;
namespace WindowsFormsApplication2
{
class OraTest
{
OracleConnection con;
public void Connect()
{
con = new OracleConnection();
con.ConnectionString = "User Id=<username>;Password=<password>;Data Source=<datasource>";
con.Open();
Console.WriteLine("Connected to Oracle" + con.ServerVersion);
}
public void Close()
{
con.Close();
con.Dispose();
}
}
}