Connecting to Oracle 10g from .NET

Posted by Xinus on Stack Overflow See other posts from Stack Overflow or by Xinus
Published on 2010-03-19T03:24:09Z Indexed on 2010/03/19 3:31 UTC
Read the original article Hit count: 701

Filed under:
|

I am trying to connect to oracle server located at some IP address but always get error as

System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> Oracle.DataAccess.Client.OracleException The provider is not compatible with the version of Oracle client at Oracle.DataAccess.Client.OracleInit.Initialize() at Oracle.DataAccess.Client.OracleConnection..cctor() --- End of inner exception stack trace --- at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString) at WebApplication1._Default.Page_Load(Object sender, EventArgs e) in C:\Users\Sunil\Documents\Visual Studio 2008\Projects\WebApplication1\WebApplication1\Default.aspx.cs:line 26

Here is a test file

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Oracle.DataAccess.Client;
namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                string oradb = "Data Source=(DESCRIPTION=(ADDRESS_LIST="
                + "(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.11)(PORT=1523)))"
                + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL)));"
                + "User Id=<user id>;Password=<some password>;";

                OracleConnection conn = new OracleConnection(oradb); // C#
                conn.Open();

            }
            catch (Exception  ex){
                Label1.Text = ex.ToString();
            }

        }
    }
}

I have installed 10gR2 client and oracle 10gR2 provider for ASP.NET. Am I missing anything ?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about Oracle