1.项目右击:选择"添加引用",添加Oracle.Data.Access.dll (之前需要安装Oracle-Client,具体参见:http://www.oracle.com/technetwork/articles/dotnet/vs2010-oracle-dev-410461.html)
2.使用代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Oracle.DataAccess.Client;
namespace testConnectionOracle
{
class Program
{
static void Main(string[] args)
{
string connectionString;
string queryString;
connectionString = "Data Source=60.217.72.134/orcl;User ID=**;PassWord=**";
queryString = "SELECT * FROM test";
OracleConnection myConnection = new OracleConnection(connectionString);
OracleCommand myORACCommand = myConnection.CreateCommand();
myORACCommand.CommandText = queryString;
myConnection.Open();
OracleDataReader myDataReader = myORACCommand.ExecuteReader();
myDataReader.Read();
Console.WriteLine("id: " + myDataReader["id"]);
myDataReader.Close();
myConnection.Close();
}
}
}