Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Problem connecting oracle to a c# program

Problem connecting oracle to a c# program

From: Ram <tadepalli_ram_at_yahoo.com>
Date: 14 Nov 2003 08:30:50 -0800
Message-ID: <8343c21c.0311140830.15b37814@posting.google.com>


Hi folks,
  I am writing a web service program in c#. I am using oracle as the database. The web service program has a method named getInfoFromID()which returns a person based upon an ID.

When i try to fetch the record of a person using getInfoFromID() in the web service program,I am getting some exception.I am using oracle (SQL plus) as the database.  

When i execute the web service program, everything works fine. i.e. i get the http://localhost/InfoService/Records.asmx and when i click on the "getInfromFromID" link, i get
http://localhost/InfoService/Records.asmx?op=getInfoFromID page. When i enter a valid ID value and say invoke i get http://localhost/InfoService/Records.asmx/getInfoFromID with the following exception:  

System.ApplicationException: Failed to connect to data source ---> System.DllNotFoundException: Unable to load DLL (oci.dll).

   at System.Data.OracleClient.DBObjectPool.GetObject(Object owningObject, Boolean& isInTransaction)

   at System.Data.OracleClient.OracleConnectionPoolManager.GetPooledConnection(String encryptedConnectionString, OracleConnectionString options, OracleConnection owningObject, Boolean& isInTransaction)

   at System.Data.OracleClient.OracleConnection.OpenInternal(OracleConnectionString parsedConnectionString, Object transact)

   at System.Data.OracleClient.OracleConnection.Open()    at PersonInfo.PersonDatabase.getInfoFromID(Int32 id) in c:\doc\info\personinfo\persondatabase.cs:line 30

Following is my code:  

Records.asmx.cs



using System.Data;

using System.Diagnostics;

using System.Web;

using System.Web.Services;

using PersonInfo;

namespace InfoService

[WebService(Description="<b>This service lets universities Update and lookup student status with the fictitious security department infoBase</b>",Namespace="http://www.cs.uh.edu/cosc4319")]

public class Records : System.Web.Services.WebService

{

public Records()

{

InitializeComponent();

}

..................

[WebMethod(Description="<i>Returns the Person with the given unique (int) ID</i>")]

public Person getInfoFromID(int id)

{

Person thePerson = new Person();

PersonDatabase personDB = new PersonDatabase();

personDB.getInfoFromID(id);    //---------------------------Line 88

return thePerson;

}

}

}


PersonDatabase.cs


using System;

using System.Data.OracleClient;

namespace PersonInfo

public class PersonDatabase

{

public PersonDatabase()

{

}

public Person getInfoFromID(int id)

{

OracleConnection nwindConn = null;

OracleDataReader oReader = null;

nwindConn = new OracleConnection("Data
Source=Oracle;UID=system;PWD=cougar;Integrated Security=yes;");

Person thePerson = new Person();

try

{

nwindConn.Open();                   //---------------------------Line
30

OracleCommand cmd = nwindConn.CreateCommand();

cmd.CommandText = "select
LastName,EntryDate,WithdrawalDate,FirstName,ID,Status,VisaDate,RegistrationDate from PersonInfo where ID =" + id;

oReader = cmd.ExecuteReader();

// while(oReader.Read())

// {

//

//

// }

}

catch (Exception ex)

{

throw new ApplicationException("Failed to connect to data source",ex);   //-----Line 64

}

finally

{

if(nwindConn != null)

{

nwindConn.Close();

nwindConn = null;

}

if(oReader != null)

{

oReader.Close();

oReader = null;

}

}

return thePerson;

}

}

}

I have checked references and other things.Everything seems to be fine but for the exception.

I got the data source name from control panel -> Administrative tools -> Data Sources (ODBC) -> System DSN (tab).

It says:

System Data Sources

Name                         Driver

Oracle                       Oracle in OraHome 92

 

I have been struggling with this for some hours. Could anyone help me out.  

Thanks and Regards.

Ram Received on Fri Nov 14 2003 - 10:30:50 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US