我是使用数据库的初学者。我正在尝试从 C# 应用程序访问 Oracle10g 数据库。但是当我这样做时,我得到了这个错误:
ORA-12154: TNS:could not resolve the connect identifier specified"
我正在使用以下代码:
string oradb = "Data Source=ORCL;User Id=system;Password=goodbye;";
OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();
连接字符串oradb
是否有错误?
最佳答案
启动 Visual Studio
,打开 View
菜单 + Server Explorer。
- 鼠标右键单击
数据连接
+添加连接
+ 选择Oracle 数据库
- 服务器名称:
localhost
或您机器的名称
,设置用户名和密码,然后单击“测试连接”以验证上述参数。如果测试成功,请按 OK。
从属性窗口中你可以获得连接字符串,它看起来应该是这样的:
Data Source=localhost;Persist Security Info=True;User ID=scott;Password=***********;Unicode=True
关于c# - 将 C# 应用程序与 Oracle 10g 连接 : ORA-12154: TNS:could not resolve the connect identifier specified,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12445201/