0

I want to connect Oracle Database in .net platform using C#

and here is some code

  _connectionString = "Provider=MSDAORA.1;Data Source=yong;User ID=XXXX;Password=XXXX";

  using (OdbcConnection sqlConnection = new OdbcConnection(_connectionString))
            {
                using (OdbcDataAdapter adapter = new OdbcDataAdapter())
                {
                    try {
                        adapter.SelectCommand = new OdbcCommand(cmdText, sqlConnection);
                        adapter.SelectCommand.CommandType = commandType;
                        adapter.SelectCommand.CommandTimeout = _commandTimeOut;
                        adapter.SelectCommand.Connection.Open();
                        adapter.Fill(dtResult);
                        }
                catch (Exception ex)
                {
                    throw ex;
                }
               }
            }

when I try this code, it throws error like

" msdaora.1' provider is not registered on the local machine "

I don't get what is a problem and how to fix this. How do I register a msdaora.1 provider on the local machine and what's wrong with my code?

4

1 回答 1

0

尝试下载并安装 Oracle 数据访问组件。以下是32 位64 位版本的链接。另外,根据个人经验,我会使用 oracle OleDb 适配器而不是那个适配器,但那是因为我在使用其他适配器连接到 RAC 集群时遇到了麻烦。

编辑:当您将应用程序部署到没有安装 ODAC 的环境时,您也会遇到问题,所以这里有一些进一步的建议阅读

于 2013-05-07T03:48:17.950 回答