C#中的Oracle Connection-连接字符串 [英] Oracle Connection in C# - connection string
问题描述
我当前正在尝试使用C#构建应用程序并将其连接到在Oracle 11g中运行的实时数据库. 我有以下连接详细信息
I'm currently trying to build an application in C# and connecting it to a live db running in 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();
我能够使用VS使用的连接字符串在Server Explorer中添加连接,但是在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();
An unhandled exception of type 'System.NullReferenceException' occurred in
Oracle.DataAccess.dll
很抱歉,如果这是一个基本问题,我是VS和Oracle的新手,无法在网络的其他部分找到解决方案.提前致谢.
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. Thanks in advance.
推荐答案
我的代码正在运行.我应该阅读Oracle文档(下面参考).
My code is now working. I should've read the Oracle documentation (reference below).
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();
这篇关于C#中的Oracle Connection-连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!