Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-28-2007, 04:36 PM   #1
Registered: Jun 2004
Distribution: Mandrake 10, SUSE 10.x, DEbian
Posts: 125

Rep: Reputation: 15
using oracle xe 10g with c# in monodevelop

Hi there people, after a sucessfull installation of oracle xe 10g (the free one) I will like to do a programm in C# with monodevelop.

I have unlocked the HR account via http://localhost:1521/apex login as system account.

Im following the examples at but like is for another version of oracle that have scott and tiger.

I have tryied with a slight modification of the code that follows, but Im getting nowhere... the code in monodevelop compile without errors or warnings...

using System;
using System.Data;
using System.Data.OracleClient;

public class Test
	public static void Main (string[] args)
		string connectionString =
			"Server=//localhost/XE;" +
			"User ID=hr;" +
		OracleConnection dbcon = null;
		dbcon = new OracleConnection (connectionString);
		dbcon.Open ();
		OracleCommand dbcmd = dbcon.CreateCommand ();
		string sql = "SELECT * FROM COUNTRIES";
		dbcmd.CommandText = sql;
		OracleDataReader reader = dbcmd.ExecuteReader ();
		while (reader.Read ()) {
			string employeeName = (string) reader["ename"];
			string job = (string) reader["job"];
			Console.WriteLine ("Employee Name: {0}  Job: {1}",
			employeeName, job);
			System.Console.WriteLine( "." );
		// clean up
		reader.Close ();
		reader = null;
		dbcmd.CommandText = sql;
		dbcmd.ExecuteNonQuery ();
		dbcmd.Dispose ();
		dbcmd = null;
		dbcon.Close ();
		dbcon = null;
But when executed I get the following error

Unhandled Exception: System.Data.OracleClient.OracleException: Could not allocate the Oracle environment.
in <0x00294> System.Data.OracleClient.Oci.OciGlue:CreateConnection (OracleConnectionInfo conInfo)
in <0x00049> System.Data.OracleClient.OracleConnectionPoolManager:CreateConnection (OracleConnectionInfo info)
in <0x0003f> System.Data.OracleClient.OracleConnectionPool:CreateConnection ()
in <0x0010a> System.Data.OracleClient.OracleConnectionPool:GetConnection ()
in <0x000e3> System.Data.OracleClient.OracleConnection:Open ()
in (wrapper remoting-invoke-with-check) System.Data.OracleClient.OracleConnection:Open ()
in [0x00010] (at /home/moi/Desktop/csharp/oracle/oracle/Main.cs:17) Test:Main (System.String[] args)

The error is from the line

dbcon.Open ();
I guess for the moment that the connection string perhaps is not the correct and is for that reason the oracle enviroment can't be allocated... or is that I can't use the connection from C#?????, also I have tried to use de "Database Browser" that come inside Monodevelop, but I cant seem to be able to connect it... I dont know the combination that work.

I can connect to oracle via

$ /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/scripts/
And in the sql plus console
SQL > conn hr/hr@localhost/XE
SQL > disconnect
Disconnected from Oracle Database 10g Express Edition Release - Production

Only for extra information the message of the exception come from this source line 105 of the function called CreateConnection in line 101 of the source and the Open function (callee) in line 185.

Last edited by hgb; 02-28-2007 at 04:39 PM.
Old 03-01-2007, 03:44 PM   #2
Registered: Jun 2004
Distribution: Mandrake 10, SUSE 10.x, DEbian
Posts: 125

Original Poster
Rep: Reputation: 15
My error was that there is no HOME_DIRECTORY set, then


Last edited by hgb; 04-09-2007 at 02:17 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
RHAS 3.0 i64, Oracle 10g, Oracle RAC, and ASM xmdms Linux - Enterprise 10 01-05-2007 11:07 PM
Help with Oracle 10g brazilian_user Linux - Networking 2 02-09-2006 02:47 PM
HP Itanium with Oracle 10G xmdms Linux - Enterprise 4 12-04-2004 12:25 AM
Oracle 10g on Mandrake 10.0 ? cafletch Mandriva 0 09-15-2004 07:40 PM
Oracle 10G vs 9i sashie Linux - Software 0 06-07-2004 02:37 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:16 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration