c#连接oracle 数据库

 项目需引用:Oracle.ManagedDataAccess.dll


string connectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["oracleDB"].ToString(); OracleConnection connB = new OracleConnection(connectionString); connB.Open(); Console.WriteLine("测试数据库连接成功!"); Console.WriteLine(); connB.Close();

 

配置文件

 <add name="oracleDB" providerName="System.Data.OracleClient" connectionString="Data Source=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 9000)) ) (CONNECT_DATA =(SERVICE_NAME = orcl))); User Id=system;Password=123;"  />    

 

上一篇:DELPHI 调用系统 ADO 配置窗体 提高软件易用性


下一篇:C# 链接 sql server 数据库字符串