当我打开SQL命令行时,我写了CONNECT username/[email protected][//]host[:port][/service_name]
,它将我连接到数据库就好了。但是,我无法使用连接字符串从.NET项目进行连接。我尝试了很多东西,例如<add name="ConnectionString" connectionString="Data Source=username/[email protected][//]host[:port][/service_name];" />
和<add name="ConnectionString" connectionString="server=tcp:host;Initial Catalog=service_name; user id=username; password=password; Connection Timeout=180;" providerName="System.Data.OracleClient" />
,但目前为止没有任何工作。每当我得到sconn.Open();
在以下几点:如何从.NET连接到Oracle DB?
var CurrentConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sconn = new SqlConnection(CurrentConnectionString);
sconn.Open();
我几乎总是出现以下错误:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)
我怎样才能连接到数据库是否正常?
http://www.connectionstrings.com/oracle/ – Plutonix
服务器可能被配置为不允许远程连接。这在所有主要的RDBMS服务器,MSSQL,PostgreSQL,MySql中都是一样的,我想Oracle也是如此。 如果它不允许远程连接,那么即使连接字符串正确,它也不可访问。 –