.NETGURU
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, Dot Net Guruhew
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. :)

Dot Net Guruhew 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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification