简体   繁体   English

C# 中的 Oracle 连接 - 连接字符串

[英]Oracle Connection in C# - connection string

I'm currently trying to build an application in C# and connecting it to a live db running in Oracle 11g.我目前正在尝试用 C# 构建一个应用程序,并将其连接到在 Oracle 11g 中运行的实时数据库。 I have the following connection details我有以下连接详细信息

Host IP: 10.204.1.3 
Port: 1521
DB Name: PROD

My source code我的源代码

string connString = "DATA SOURCE=10.204.1.3:1521/PROD;PERSIST SECURITY" +
"INFO=True;USER ID=username; PASSWORD=userpass";
OracleConnection conn = new OracleConnection(connString);
conn.Open();

I was able to add a connection in Server Explorer with the Connection String used by VS but is having the error below in conn.Open();我能够使用 VS 使用的连接字符串在服务器资源管理器中添加连接,但在 conn.Open(); 中出现以下错误;

An unhandled exception of type 'System.NullReferenceException' occurred in 
Oracle.DataAccess.dll

Sorry if this is a basic question, I'm new in VS, and Oracle and can't find the solution in the other part of the web.抱歉,如果这是一个基本问题,我是 VS 和 Oracle 的新手,无法在网络的其他部分找到解决方案。 Thanks in advance.提前致谢。

My code is now working.我的代码现在正在运行。 I should've read the Oracle documentation (reference below).我应该阅读 Oracle 文档(参考如下)。

string connString = "DATA SOURCE=10.204.3.1:1521/PROD;" +
"PERSIST SECURITY INFO=True;USER ID=username; password=password; Pooling 
=False;";

OracleConnection conn = new OracleConnection();
conn.ConnectionString = connString;
conn.Open();

Reference: http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/appdev/dotnet/Web_version_Fully_Managed_ODPnet_OBE/odpnetmngdrv.html参考: http : //www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/appdev/dotnet/Web_version_Fully_Managed_ODPnet_OBE/odpnetmngdrv.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM