[英]c# connect to oracle using ODBC
I am trying to connect to a remote Oracle database using ODBC in c#. 我正在尝试使用c#中的ODBC连接到远程Oracle数据库。
i make a test code for reproduce de error 我做了一个测试代码来重现错误
String sql = "SELECT * FROM ALL_TABLES";
OdbcConnection conn = new OdbcConnection();
conn.ConnectionString = "Driver={Oracle in instant_client_12};Server=192.168.56.101;Uid=SYS;Pwd=somepassword;";
conn.Open();
OdbcCommand command = conn.CreateCommand();
command.CommandText = sql;
System.Data.DataTable dt = new System.Data.DataTable();
OdbcDataAdapter da = new OdbcDataAdapter(command);
da.Fill(dt);
conn.Close();
Console.WriteLine("Filas: "+dt.Rows.Count);
Console.ReadKey();
and i get the next error in 4th line, conn.Open() 我在第四行中遇到下一个错误conn.Open()
ERROR [HY000] [Oracle][ODBC][Ora]ORA-12560: TNS:protocol adapter error
ERROR [IM006] [Microsoft][Administrador de controladores ODBC] Error de SQLSetConnectAttr del controlador
ERROR [HY000] [Oracle][ODBC][Ora]ORA-12560: TNS:protocol adapter error
sqlplus works fine sqlplus正常工作
sqlplus.exe SYSTEM/somepassword@PRUEBA
sqlplus.exe系统/ somepassword @ PRUEBA
SQL*Plus: Release 12.1.0.2.0 Production on Thu Mar 26 19:45:37 2015
SQL * Plus:12.1.0.2.0版本于2015年3月26日星期四19:45:37投入生产
Copyright (c) 1982, 2014, Oracle.
版权所有(c)1982、2014,Oracle。 All rights reserved.
版权所有。
And PRUEBA = 192.168.56.101, setted in tnsname.ora 在tnsname.ora中设置的PRUEBA = 192.168.56.101
Any body have idea of what happens? 任何人都知道会发生什么? i need some help.
我需要协助。 Thank you for your time
感谢您的时间
See your connection string: 查看您的连接字符串:
conn.ConnectionString = "Driver={Oracle in instant_client_12};Server=192.168.56.101;Uid=SYS;Pwd=somepassword;";
You don't specify any database name, just a server. 您无需指定任何数据库名称,只需指定服务器即可。 A server may host several Oracle DB's.
一台服务器可以托管多个Oracle DB。
Try one of the following 尝试以下方法之一
conn.ConnectionString = "Driver={Oracle in instant_client_12};DBQ=PRUEBA;Uid=SYS;Pwd=somepassword;";
conn.ConnectionString = "Driver={Oracle in instant_client_12};CONNECTSTRING=PRUEBA;Uid=SYS;Pwd=somepassword;";
conn.ConnectionString = "Driver={Oracle in instant_client_12};Server=PRUEBA;Uid=SYS;Pwd=somepassword;";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.