将C#应用程序与Oracle 10g连接:ORA-12154:TNS:无法解析指定的连接标识符 [英] Connecting C# app with Oracle 10g: ORA-12154: TNS:could not resolve the connect identifier specified

查看:959
本文介绍了将C#应用程序与Oracle 10g连接:ORA-12154:TNS:无法解析指定的连接标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用数据库的初学者。我试图从c#应用程序访问Oracle10g数据库。但是当我这样做,我得到这个错误:


ORA-12154:TNS:无法解析指定的连接标识符<

  string oradb =Data Source = ORCL; User Id = system; Password = goodbye;; 
OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();

连接字符串中是否有错误 oradb

解决方案

开始 Visual Studio ,打开 菜单+服务器资源管理器。


  1. 鼠标右键单击数据连接 + 添加连接 +选择 Oracle数据库

  2. localhost 您的计算机名称,设置用户名和密码并单击测试连接以验证上述参数


  3. 在属性窗口中,您可以获取连接字符串,它应该看起来像:

     数据源= localhost; Persist安全信息= True;用户ID = scott;密码= ***********; Unicode = True 


    I am a beginner in working with databases. I am trying to access Oracle10g database from a c# application. But when I do so i get this error:

    ORA-12154: TNS:could not resolve the connect identifier specified"

    I'm using the following code:

    string oradb = "Data Source=ORCL;User Id=system;Password=goodbye;";
    OracleConnection conn = new OracleConnection(oradb);  // C#
    conn.Open();
    

    Is there an error in the connection string oradb?

    解决方案

    Start the Visual Studio, open View menu + Server Explorer.

    1. Right mouse click on Data Connection + Add Connection + Select Oracle Database
    2. server Name : localhost or name of your machine, set username & password and click on Test Connection to verify the above parameters. Press OK if test is succeeds.

    From properties windows you can obtain connection String and it should be look a like:

    Data Source=localhost;Persist Security Info=True;User ID=scott;Password=***********;Unicode=True
    

    这篇关于将C#应用程序与Oracle 10g连接:ORA-12154:TNS:无法解析指定的连接标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆