Developing an application using Oracle 10g under Visual Studio 2010
You can see the Oracle Database 10g in the server explorer view of Visual studio like Sql Server included by default in the VS2010 for example.

So you need to install the ODTwithODAC112030 tools for visual studio and you can dowload it from this link:
http://www.oracle.com/technetwork/database/windows/downloads/index-101290.html
I suggest you to avoid problems to install it in the same folder of Oracle 10g installation.
Once everything is installed correctly you need to do some configurations in your system.
Open the properties of your Computer, in the tab Advanced open in the bottom of the window the environment variables and add a new entry. Call the variable name :oracle_sid and in the variable value :xe.
Another configuration is needed. You open this path: C:\oraclexe\produit\product\11.2.0\client_1\Network\Admin\Sample
and you edit the tnsnames.ora with notepad like below:
and you copy the file under the admin folder.
Once finished, you can add a new datasource and choose the ODP provider :

Now we have all needed configurations to begin developing!
Here's a code snippet to help you using the oracle provider of Oracle 10g with the right connection string:
You may have OracleConnection not recognized .So add a new Reference and browse Oracle.DataAccess.dll
You can find that dll under this path : C:\oraclexe\app\oracle\product\10.2.0\server\BIN
once added you import the needed DLL:
Happy coding for Oracle Users
So you need to install the ODTwithODAC112030 tools for visual studio and you can dowload it from this link:
http://www.oracle.com/technetwork/database/windows/downloads/index-101290.html
I suggest you to avoid problems to install it in the same folder of Oracle 10g installation.
Once everything is installed correctly you need to do some configurations in your system.
Open the properties of your Computer, in the tab Advanced open in the bottom of the window the environment variables and add a new entry. Call the variable name :oracle_sid and in the variable value :xe.
Another configuration is needed. You open this path: C:\oraclexe\produit\product\11.2.0\client_1\Network\Admin\Sample
and you edit the tnsnames.ora with notepad like below:
<data source alias> = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = URPCNAME)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )and you copy the file under the admin folder.
Once finished, you can add a new datasource and choose the ODP provider :
Now we have all needed configurations to begin developing!
Here's a code snippet to help you using the oracle provider of Oracle 10g with the right connection string:
private DataTable GetData(OracleCommand cmd){ DataTable dt = new DataTable(); OracleConnection conn = new OracleConnection(); conn.ConnectionString = "DATA SOURCE=;PERSIST SECURITY INFO=True;USER ID=SYSTEM ; PASSWORD=SYSTEM;"; OracleDataAdapter sda = new OracleDataAdapter(); cmd.Connection = conn; try { conn.Open(); sda.SelectCommand = cmd; sda.Fill(dt); } catch (Exception ex) { conn.Close(); } return dt;}You may have OracleConnection not recognized .So add a new Reference and browse Oracle.DataAccess.dll
You can find that dll under this path : C:\oraclexe\app\oracle\product\10.2.0\server\BIN
once added you import the needed DLL:
using Oracle.DataAccess.Client;Happy coding for Oracle Users
No comments:
Post a Comment