C#连接oracle数据库报“ORA-12154: TNS: 无法解析指定的连接标识符”错误看清楚内容再说哦!!

连接成功代码:try{stringconstring="datasource=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=... 连接成功代码: try {
string constring = "data source= (DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = billow) ));user=sfcfa;password=sfcfa;";//ConfigurationManager.AppSettings["FAKey"]; //
OracleConnection conn = new OracleConnection(constring);
string orasql = "Select * from sfcmo"; //= "select * from sfcfa.sfcmo where seq in('" + this.textBox1.Text.ToString() + "') "; OracleDataAdapter ora1 = new OracleDataAdapter(orasql, conn);
DataSet orale = new DataSet();
ora1.Fill(orale, "123");
dataGridView1.DataSource = orale.Tables[0].DefaultView; }
catch (Exception EX)
{
label1.Text = EX.ToString();
}

我需求写的代码
try {
string constring = "data source=BILLOW;user=sfcfa;password=sfcfa;";//ConfigurationManager.AppSettings["FAKey"]; //
OracleConnection conn = new OracleConnection(constring);
string orasql = "Select * from sfcmo"; //= "select * from sfcfa.sfcmo where seq in('" + this.textBox1.Text.ToString() + "') "; OracleDataAdapter ora1 = new OracleDataAdapter(orasql, conn);
DataSet orale = new DataSet();
ora1.Fill(orale, "123");
dataGridView1.DataSource = orale.Tables[0].DefaultView; }
catch (Exception EX)
{
label1.Text = EX.ToString();
}
报错如下图label1中别跟我说-->ORACLE监听器错误
plsql和SQLPlus都能连接上

本地数据库配置文件TNSNAMES:

# tnsnames.ora Network Configuration File: F:\app\Administrator\product\11.2.0\dbhome_5\NETWORK\ADMIN\tnsnames.ora# Generated by Oracle configuration tools.
ORACLR_CONNECTION_DATA = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
BILLOW = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = billow)
)
)
LISTENER_BILLOW = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

求大神解决我的需求!!!!所有家当就这点了 帮帮忙
展开
 我来答
匿名用户
2013-01-24
展开全部
string constring = "data source=BILLOW;user=sfcfa;password=sfcfa;";

修改为:

string constring = "Data Source=BILLOW;Persist Security Info=True;User ID=sfcfa;Password=sfcfa"

看看行不行?
我本机可以跑的配置是上面这样写的。

如果不行。
你可以尝试一下, 开始 --> 运行兄慧 cmd

D:\>tnsping BILLOW

然后观察一下, 会提示:

已使用的参数文件:
D:\oracle\......\sqlnet.ora

注意观察一下, 这个 D:\oracle\......\世握 路径, 是不是你那里搜尘庆的那个 tnsnames.ora 所在的路径。

(假如机器上面安装了多个 不同版本的 Oracle 的时候, 会有这个问题)
百度网友3b2fd27
2013-01-24 · TA获得超过278个赞
知道小有建树答主
回答量:166
采纳率:0%
帮助的人:81.2万
展开全部
BILLOW =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = billow)
)
)

把localhost改成哪橡IP地粗缓老址试试岩升看
追问

这个报错持续中。。

 string constring = "Data Source=BILLOW;Persist Security Info=True;User ID=sfcfa;Password=sfcfa";

       

           

           

     

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
云影飞非
2020-09-28 · TA获得超过792个赞
知道小有建树答主
回答量:619
采纳率:100%
帮助的人:188万
展开全部
  1.  以高好管理员身份运行程序

  2. 目录不颤誉能有茄念段括号

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式