Nov.01

How to Connecting to Oracle from Visual Studio

How to Connecting to Oracle from Visual Studio

Hello everyone ,

 

We have today the steps for how to connecting to oracle from visual studio 2012.

 

First of all we should have to install the following :

  1. Visual Studio 2012 or higher from here .
  2. ODAC with Oracle Developer Tools for Visual Studio from here .

 

After install Visual Studio we cannot found the ODP.Net data provider under oracle DB data source as the following :

Note: To open data source ( from View -> Server Explorer -> connect to database ).

BeforeInstallODAC

 

When we installed ODAC the ODP.Net data provider which we will use it to connecting to oracle Db appeared under oracle DB data source as the following :

AfterInstallODAC

Click on ( ODP.Net , managed Driver ) then fill connect information.

 

To connecting oracle DB from C# code , add a reference of the assembly Oracle.DataAccess.dll in project

add reference

 

 

Use and replace your connect information in the following code :

OracleConnection con = new OracleConnection();
con.ConnectionString = "User Id=<username>;Password=<password>;Data Source=<datasource>";
con.Open();
Console.WriteLine("Connected to Oracle" + con.ServerVersion);
con.Close();
con.Dispose();

 

Enjoy ;)

.NET
Share this Story:
  • facebook
  • twitter
  • gplus

About Abdulmajeed