[英]Error when using OracleConnection.Open() ORA-00303: Network Library: Name-Value syntax error ODP.NET managed dll
當我點擊 source.Open(); 時出現此錯誤一行代碼,我不知道為什么。 我使用的是非托管 dll,我正在嘗試升級到 Oracle.ManagedDataAccess.dll 64 位版本,我的項目正在使用 .NET 框架 4。TNS 字符串在生產 tnsnames.ora 文件中工作(我已經替換了各種元素名稱和值)。 從錯誤看來,顯然應該是錯誤的,但我無法讓它工作。
app.config 中的 TNS:
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="ABC_DEF_GH" descriptor="ABC_DEF_GH = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = server.company.com)(PORT = 11111))(CONNECT_DATA = (SERVICE_NAME = ABC_DEF_GH.company.com)))"/>
</dataSources>
</version>
</oracle.manageddataaccess.client>
代碼片段:
using (OracleConnection source = new OracleConnection("UserId=xxxxx;Password=xxxxxx;DataSource=ABC_DEF_GH;"))
{
OracleCommand command = new OracleCommand(transferConfig.QueryLogic + WhereClause, source);
//The time (in seconds) to wait for the command to execute. The default is 30 seconds.
command.CommandTimeout = transferConfig.SourceCommandTimeout;
// command.Connection.ConnectionTimeout is set in the connection string only
source.Open();
//...
}
錯誤:ORA-00303:網絡庫:名稱-值語法錯誤
您的連接字符串應遵循以下格式:
SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;
請檢查此格式,該錯誤與使用不正確的連接字符串格式有關。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.