linux oracle无法解析指定的连接标识符,这是错误ORA-12154:TNS:无法解析指定的连接标识符?...

I've this 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()); }

Same code in both projects,

in project1 "WinForm" Is Working correctly

in project2 "Excel 2007 addins" Following error appears:

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

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

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

Visual Studio, open View menu + Server Explorer.

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.

OQwOV.png

解决方案

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

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

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";

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.

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

And restart your vs then run your project ....

NOTE:- SYSTEM RESTART IS necessary FOR SOLVE THIS TYPES OF ERROR.......

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值