从vs 2010连接到oracle数据库

从vs 2010连接到oracle数据库

问题描述:

大家好,

我们在oracle应用服务器上运行了一些oracle应用程序,我们还有其他Web应用程序在其他服务器和SQL服务器上运行,所以主要是我想问的问题: - 有没有办法编写一个可以使用VS 2010连接到64位机器上的oracle数据库的Web应用程序,它可以将数据从Oracle数据库迁移和检索到SQL服务器?



非常感谢。

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.

将ref添加到System.Data.OracleClient并定义你的连接。



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); 
    }
  }