Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'Oracle.DataAccess' error

Status
Not open for further replies.

ace333

Programmer
Jul 12, 2005
105
CH
using Oracle.DataAccess.Client;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

OracleConnection oracleConn = new OracleConnection();
oracleConn.ConnectionString = "User Id=xxxxx;Password=xxxxx;Data Source=xxxxx;";
oracleConn.Open();

}

I'm using to this code in a c# page to try to connect to a oracle 9.2 database
and i'm getting the error that 'Oracle.DataAccess' could not be loaded.
I have done all the things with permissions et cetera, any ideas. the Oracle.DataAccess.DLL. file is in the oracle bin

 
I think you want to use
System.Data.OracleClient;
Marty
 
That just gave me more errors with the same code !!!
 
this should get you closer, you can post the errors and someone could help
Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OracleClient;

namespace CSTestWebForms
{
	/// <summary>
	/// Summary description for SelectSysdate.
	/// </summary>
	public class SelectSysdate : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			try
			{
				string ConnectSysdate = TestConnection();
				Label1.Text = "The oracle sysdate is " + ConnectSysdate;
			}
			catch(Exception ex)
			{
				Label1.Text = ex.Message;
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	
		public static string TestConnection()
		{ 
			string myConnString = "User ID=bush;Password=bonehead;Data Source=texas;"; 
			OracleConnection myConnection = new System.Data.OracleClient.OracleConnection(myConnString);
			OracleCommand myCommand = new System.Data.OracleClient.OracleCommand();
			myCommand.Connection = myConnection;
			myCommand.CommandType = CommandType.Text;
			myCommand.CommandText = "SELECT sysdate from dual";
			System.Data.OracleClient.OracleDataReader dr;
			try 
			{
				myConnection.Open();
				dr = myCommand.ExecuteReader();
				if (dr.Read())
				{
					return dr.GetValue(0).ToString();
				}
				else
				{
					return "no connection";
				}
			}	
			catch (System.Data.OracleClient.OracleException OraEx) 
			{
				throw new Exception(OraEx.Message);
			}
			catch (System.Exception SysEx) 
			{
				throw new Exception(SysEx.Message);
			}
			finally 
			{
				myConnection.Close(); 
			}
		}
	}
}
Marty
 
Cheers, but the problem was that I had not added the *.dll file as a reference to the project. I only remembered that after seeing it on another site .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top