當我打開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也是如此。 如果它不允許遠程連接,那麼即使連接字符串正確,它也不可訪問。 –