Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi all ,
we have some oracle applications running on an oracle application server and we have other web application that running on other servers and SQL server too, so mainly what i want to ask about :- is there any way to write a web application that can connect to oracle database on a 64bit machine using VS 2010, that can migrate and retrieve data from Oracle Database to SQL server ??
 
Thank you so much.
Posted 25-Sep-12 0:21am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Add ref to System.Data.OracleClient and define your connection.
 
using System.Data.OracleClient;
 
 
private static string CONNECTION_STRING =
  "User Id=myUserID;Password=myPassword;Data Source=(DESCRIPTION=" +
  "(ADDRESS=(PROTOCOL=TCP)(HOST=myserver.server.com)(PORT=yourPort#))" +
  "(CONNECT_DATA=(SID=yourSID)));";
 
using (OracleConnection connection = new OracleConnection()) 
  { 
    connection.ConnectionString = CONNECTION_STRING; 
    connection.Open(); 
    Console.WriteLine("State: {0}", connection.State); 
    Console.WriteLine("ConnectionString: {0}", 
                      connection.ConnectionString); 
    
    OracleCommand command = connection.CreateCommand(); 
    string sql = "SELECT * FROM MYTABLE"; 
    command.CommandText = sql; 
 
    OracleDataReader reader = command.ExecuteReader(); 
    while (reader.Read()) 
    { 
      string myField = (string)reader["MYFIELD"]; 
      Console.WriteLine(myField); 
    }
  }
  Permalink  
Comments
rushdi obeidat at 26-Sep-12 2:50am
   
hi, thank you so much for the solution , but when i tried it out the following error appears : - System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.
Kuthuparakkal at 26-Sep-12 3:08am
   
Install Oracle Instant Client( instantclient-basiclite-nt-11.2.0.3.0.zip will do) :
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
Once you install find the following dlls:
oraociicus10.dll
oci.dll
orannzsbb10.dll
oraocci10.dll
 
Copy the above 4 dlls into the same directory as your executable.
Rajesh Varatharajan at 20-Jun-13 5:30am
   
hi,
i tried the above but the following error came:

error C2039: 'OracleClient' : is not a member of 'System::Data'
CHill60 at 20-Jun-13 9:29am
   
You must have a more recent version of VisualStudio than Kuthuparakkal - OracleClient has been deprecated. See this https://blogs.oracle.com/databaseinsider/entry/microsoft_deprecates_systemdataoracleclient_net_developers_for_oracle_should_migrate_to_oracle_data_provider_for_net[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 20 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100