help with ado.net and oracle functions
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-oracle' list.


Isabelle M.
-- Moved from [aspngfreeforall] to [ngfx-oracle] by Tim Musschoot <Click here to reveal e-mail address> --

Hello

I'm new to ado.net and I'm trying to call an oracle function.
the function has an input parameter as an Integer and returns an integer. For some reasons, I cannot call the function properly. Any advice, web links, tutorial, specific to the Oracle function that you might know of and refer me to? I can do this in SQL server no problem but not in Oracle.

Thanks for anything

Isabelle

Reply to this message...
 
    
Moore, Matthew
Here is something like I use. This function will get a Tech's Name from the Database. I pass aID into the function which is the Tech's ID number and it will return the Tech's name. You'll even have my exception handling in there.

iTechID = input parameter in the SP
oTechName = output parameter in the SP

Oracle rules. :)

Matthew T. Moore
Software Engineer - AUTEC
Click here to reveal e-mail address

public string GetTechName(string aID)
{
string TechName = "";

OleDbConnection myConnection = new OleDbConnection(HelpConnString);
OleDbCommand myCommand = new OleDbCommand("SP_GET_TECH_NAME", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;

myCommand.Parameters.Add(new OleDbParameter("iTechID", OleDbType.VarChar, 50, ParameterDirection.Input, true, 0,0,"TECHID", DataRowVersion.Current, aID ));

OleDbParameter myParam = new OleDbParameter("oTechName", OleDbType.VarChar, 18);
myParam.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(myParam);

myParam = new OleDbParameter("oTechID", OleDbType.VarChar, 18);
myParam.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(myParam);

//Test to see if the new row was added
try
{
    myConnection.Open();
    myCommand.ExecuteNonQuery();
    TechName = myCommand.Parameters["oTechName"].Value.ToString().Trim();
}
catch(NullReferenceException NullE)
{
    //ignore null references. assign to dummy to avoid warning
    string msg = NullE.Message;
}
catch (OleDbException e)
{    
    myConnection.Close();
    throw e;                
}

    //Close the active connection to the database.
    myConnection.Close();
    return (TechName);
}

-----Original Message-----
From: Isabelle M. [mailto:Click here to reveal e-mail address]
Sent: Wednesday, May 29, 2002 1:12 PM
To: ngfx-oracle
Subject: [ngfx-oracle] help with ado.net and oracle functions

-- Moved from [aspngfreeforall] to [ngfx-oracle] by Tim Musschoot <Click here to reveal e-mail address> --

Hello

I'm new to ado.net and I'm trying to call an oracle function.
the function has an input parameter as an Integer and returns an integer. For some reasons, I cannot call the function properly. Any advice, web links, tutorial, specific to the Oracle function that you might know of and refer me to? I can do this in SQL server no problem but not in Oracle.

Thanks for anything

Isabelle

Reply to this message...
 
 
System.Data.CommandType
System.Data.DataRowVersion
System.Data.OleDb.OleDbCommand
System.Data.OleDb.OleDbConnection
System.Data.OleDb.OleDbException
System.Data.OleDb.OleDbParameter
System.Data.OleDb.OleDbType
System.Data.ParameterDirection
System.NullReferenceException




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com