简体   繁体   English

在C#.Net中连接到Oracle数据库

[英]Connecting to an oracle database in C# .Net

Hi I use the following code to connect to an orace database in Visual Studio 2008 and it is falling over with the exception of ServerVersion threw an invalid operation exception at line 3: 嗨,我使用以下代码连接到Visual Studio 2008中的orace数据库,并且它崩溃了,但ServerVersion的异常在第3行引发了无效的操作异常:

m_strConnectionString = Settings.GetMandatoryConfig("databases", "SourceDB");
m_strQueryTerminator = Settings.GetConfig("databases", "QueryTerminator");
m_odbConn = new OleDbConnection(m_strConnectionString);
m_sql = new SQL(DatabaseType.AnsiSQL, false);

m_strConnectionString is a valid TNS names connection string and is as follows: m_strConnectionString是有效的TNS名称连接字符串,如下所示:

Provider=MSDAORA;Data Source=myDS;User ID=myID;Password=myPW 提供商= MSDAORA;数据源= myDS;用户ID = myID;密码= myPW

This has previously worked and is using an IIS web server to host the application. 这以前曾起作用,并且正在使用IIS Web服务器来承载应用程序。 I recently converted it from .Net 1.1 (VS 2003) to .Net 3.5/2 (VS 2008) and can't get it working as yet in VS 2008. 我最近将其从.Net 1.1(VS 2003)转换为.Net 3.5 / 2(VS 2008),现在还无法在VS 2008中正常工作。

Thanks 谢谢

Maybe you should consider using the OracleConnection class instead of the generic OleDbConnection. 也许您应该考虑使用OracleConnection类而不是通用OleDbConnection。 Doing this may give you more specific error information that what you're receiving now - and could help you find your problem quicker. 这样做可能会为您提供当前所收到的更具体的错误信息,并且可以帮助您更快地找到问题。

See here for more information on the System.Data.OracleClient namespace included with the .Net framework. 有关.Net框架随附的System.Data.OracleClient命名空间的详细信息,请参见此处。

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

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