首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从ASP.NET连接Oracle11g

从ASP.NET连接Oracle11g
EN

Stack Overflow用户
提问于 2013-06-10 11:24:20
回答 4查看 12.4K关注 0票数 1

如何连接到我的Oracle 11g release 11.2.0.1.0

我的.Net framework is 4。我的操作系统是windows 7 64 bit版本。

我从谷歌读取了一些样本并进行了测试,但它不起作用。

这是我的代码。我使用了VS2012 Express 2012 for Web

我用的是Oracle.DataAccess。任何示例代码或指令帮助都很受欢迎。

代码语言:javascript
复制
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Oracle.DataAccess.Client;

    namespace WebApplication1
    {
        public partial class index : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                OracleConnection connection = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=mySid)));User Id=xxx;Password=xxx;");
                try
                {
                    connection.Open();
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
        }

} 

这是我的错误..

代码语言:javascript
复制
Server Error in '/' Application.

The provider is not compatible with the version of Oracle client

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client

Source Error: 


Line 13:         protected void Page_Load(object sender, EventArgs e)
Line 14:         {
Line 15:             OracleConnection connection = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxx)(PORT=xxxx)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xxx)));User Id=xxx;Password=xxxx;");
Line 16:             try
Line 17:             {

Source File: c:\PLanguages\PSources\C#\WebApplication1\WebApplication1\index.aspx.cs    Line: 15 

Stack Trace: 


[OracleException (0x80004005): The provider is not compatible with the version of Oracle client]
   Oracle.DataAccess.Client.OracleInit.Initialize() +624
   Oracle.DataAccess.Client.OracleConnection..cctor() +903

[TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.]
   Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString) +0
   WebApplication1.index.Page_Load(Object sender, EventArgs e) in c:\PLanguages\PSources\C#\WebApplication1\WebApplication1\index.aspx.cs:15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +92
   System.Web.UI.Control.LoadRecursive() +54
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2013-06-11 10:03:31

我在here中找到了答案。

我只需要覆盖我的环境变量,我可以很容易地连接。

票数 2
EN

Stack Overflow用户

发布于 2013-06-11 03:26:38

使用oracle odp.net连接到oracle数据库,就可以了。

票数 0
EN

Stack Overflow用户

发布于 2014-05-22 21:28:46

我的建议是安装odp.net.x64包,你要做的就是进入工具,Libery包管理器,包管理器控制台,并进入下面的安装包odp.net.x64

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17016488

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档