时间:2021-07-01 10:21:17 帮助过:27人阅读
# listener.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = ORCL)
(ORACLE_HOME = C:\oracle\product\10.2.0\db_1)
(SID_NAME = ORCL)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.121.130)(PORT = 1521))
)
)
3、连接字符串:
string connStr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.121.130)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)));Persist Security Info=True;User ID=scott;Password=tiger;";
其中Oracle数据库服务器IP:192.168.121.130
ServiceName:ORCL
用户名:scott
密码:tiger
4、查看Oracle的实例名,用sys作为dba登录,执行语句 select name from v$database;
5,C#代码
using System; using System.Collections.Generic; using System.Configuration; using Oracle.ManagedDataAccess.Client; using System.Linq; using System.Text; namespace ADOSample { class Program { static void Main(string[] args) { string connStr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.121.130)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)));Persist Security Info=True;User ID=scott;Password=tiger;"; using (OracleConnection conn = new OracleConnection(connStr)) { string sql = "select * from dept "; conn.Open(); using (OracleCommand cmd = new OracleCommand(sql, conn)) { using (OracleDataReader dataReader = cmd.ExecuteReader()) { while (dataReader.Read()) { string obj = (string)dataReader[1]; Console.WriteLine(obj); } } } } Console.ReadKey(); } } }
ADO.Net连接Oracle
标签:linq dos key 添加 pac space host ted 2.0