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))
求大神解决我的需求!!!!所有家当就这点了 帮帮忙 展开
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))
求大神解决我的需求!!!!所有家当就这点了 帮帮忙 展开
3个回答
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 的时候, 会有这个问题)
修改为:
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 的时候, 会有这个问题)
展开全部
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地址试试看
(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地址试试看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
以管理员身份运行程序
目录不能有括号
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询