这是错误ORA-12154:TNS:无法解析指定的连接标识符? [英] this is error ORA-12154: TNS:could not resolve the connect identifier specified?

查看:3313
本文介绍了这是错误ORA-12154:TNS:无法解析指定的连接标识符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个code:

OracleConnection con = new OracleConnection("data source=localhost;user id=fastecit;password=fastecit"); 
con.Open(); string sql="Select userId from tblusers";    
OracleCommand cmd = new OracleCommand(sql, con);
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{ messageBox.Show(dr[0].Tostring()); } 

同样code在这两个项目中,

Same code in both projects,

在PROJECT1WinForm的工作正常

in project1 "WinForm" Is Working correctly

在项目2Excel 2007中加载项出现以下错误:

in project2 "Excel 2007 addins" Following error appears:

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

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

我使用C#.NET 2010,Office 2007中,Windows8的,Oracle 10g中。

I'm using C#.net 2010 ,office 2007 , windows8, oracle 10g.

当preparing到数据库的手动连接,如图中所示

When preparing a manual connection to the database, as shown in the picture

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

Visual Studio, open View menu + Server Explorer.

在数据连接点击鼠标右键+添加连接+选择Oracle数据库
服务器名称:本地主机或我的机器,设置用户名和放大器的名称;密码并点击测试连接,测试没有成功。

Right mouse click on Data Connection + Add Connection + Select Oracle Database server Name : localhost or name of my machine, set username & password and click on Test Connection, test is no succeeds.

推荐答案

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

在情况下,TNS没有定义你也可以试试这个:

In case the TNS is not defined you can also try this one:

如果您使用的是 C#.NET 2010 或VS的其他版本和Oracle 10g前preSS版或更低版本,你做一个连接字符串这样

If you are using C#.net 2010 or other version of VS and oracle 10g express edition or lower version, and you make a connection string like this:

static string constr = @"Data Source=(DESCRIPTION=
    (ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=yourhostname )(PORT=1521)))
    (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)));
    User Id=system ;Password=yourpasswrd"; 

这之后你会得到错误信息 ORA-12154:TNS:无法解析指定的连接标识符那么首先你要做的重新启动系统并运行项目

After that you get error message ORA-12154: TNS:could not resolve the connect identifier specified then first you have to do restart your system and run your project.

和如果您的Windows是64位的,那么你安装的Oracle 11g 32位,如果你安装了11g,64位,那么你安装使用Oracle开发工具的Oracle 11g的Oracle数据访问组件(ODAC)对于Visual Studio版本11.2.0.1.2或后来从OTN,并检查它在Oracle通用安装程序
请确保以下检查:

And if Your windows is 64 bit then you install oracle 11g 32 bit and if you install 11g 64 bit then you Install Oracle 11g Oracle Data Access Components (ODAC) with Oracle Developer Tools for Visual Studio version 11.2.0.1.2 or later from OTN and check it in Oracle Universal Installer Please be sure that the following are checked:

Oracle Data Provider for .NET 2.0

Oracle Providers for ASP.NET

Oracle Developer Tools for Visual Studio

Oracle Instant Client 

和重新启动VS运行项目....
注: - 系统重启是必要的求解这个错误类型.......

And restart your vs then run your project .... NOTE:- SYSTEM RESTART IS necessary FOR SOLVE THIS TYPES OF ERROR.......

这篇关于这是错误ORA-12154:TNS:无法解析指定的连接标识符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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