[Mono-list] Mono and Oracle 9i will not work
Hannes Osius
Hannes Osius <h_osius@web.de>
Wed, 2 Apr 2003 16:23:57 +0200
Hello mono-list,
I tried to connect to an Oracle 9i and I get this Error-Message:
Unhandled Exception: System.NullReferenceException: A null value was found where an object instance was required
in <0x00020> 00 System.Data.OracleClient.Oci.OciServerHandle:Attach (string,System.Data.OracleClient.Oci.OciErrorHandle)
in <0x0043a> 00 System.Data.OracleClient.Oci.OciGlue:CreateConnection (System.Data.OracleClient.OracleConnectionInfo)
in <0x0008e> 00 System.Data.OracleClient.OracleConnection:Open ()
in <0x000d5> 00 .MainClass:OracleOnlyClient (string,string)
in <0x000c7> 00 .MainClass:Main (string[])
the code:
using System;
using System.Data;
using System.Data.OracleClient;
public class MainClass
{
public static void OracleOnlyClient(string connectionString, string sqlcmd){
OracleConnection dbcon = new OracleConnection(connectionString);
OracleCommand dbcmd = new OracleCommand(sqlcmd,dbcon);
dbcon.Open();
OracleDataReader myReader = dbcmd.ExecuteReader();
Console.WriteLine("OracleClient with OracleDataReader");
while (myReader.Read()) {
object KundenID = myReader["KUNDENID"];
object Vorname = myReader["VORNAME"];
object Nachname = myReader["NACHNAME"];
object Telefonnummer = myReader["TELEFONNUMMER"];
Console.WriteLine ("KundenID: {0} Vorname: {1} Nachname: {2} Telefonnummer: {3} ", KundenID.ToString(), Vorname.ToString(), Nachname.ToString(), Telefonnummer.ToString());
}
//clean up;
myReader.Close ();
myReader = null;
dbcmd.CommandText = sqlcmd;
dbcmd.ExecuteNonQuery ();
dbcmd.Dispose ();
dbcmd = null;
dbcon.Close ();
dbcon = null;
}
public static void Main (string[] args)
{
string DataSource = "SWT02";
string UserID = "MY_ACC";
string Password = "MY_PASS";
string sqlcmd = "SELECT * FROM KUNDE";
string connectionStringOracle =
"Data Source=" + DataSource + ";" +
"User ID=" + UserID + ";" +
"Password=" + Password + ";";
MainClass.OracleOnlyClient(connectionStringOracle,sqlcmd);
}
}
On the PC is the Oracle Client 9i install in /opt/oracle
I have checkout mono and msc from the CVS and installed it.
add this in my .bashrc to get the Oracle Client work
export ORACLE_HOME=/opt/oracle
export ORACLE_USER=oracle
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
compiled my DBtest.cs with
mcs DBtest.cs -r System.Data -r System.Data.OracleClient
and run it with:
mono DBtest.exe
then I get the Error Message.
Did I forget something ?
or will the System.Data.OracleClient not work with an Oracle Client 9i?
--
Best regards,
Hannes mailto:h_osius@web.de