Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Below is code that I thought would run a function from asp.net passing it one argument, an id and return one number an integer

as well. I am able to call stored procedures from asp.net with code similar to below but those procedures added

a row of data to the table. I'm wondering is the procedure slightly different when you try to call a

function instead of a stored procedure. I would have thought not since people seem to assume that stored procedures

cover both stored procedures and functions. This is the error that I get when I try to call the function

 

Oracle.DataAccess.Client.OracleException ORA-06550: line 1, column 7: PLS-00221: 'COUNTROW' is not a procedure or is undefined ORA-06550: line 1, column 7: PL/SQL: Statement ignored at Project1.xmlApp.GetInt(String[] aParams) in c:\inetpub\wwwroot\project1\xmlapp.aspx.cs:line 273 at Project1.xmlApp.btnRead_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\project1\xmlapp.aspx.cs:line 171

 

 

Any help is greatly appreciated.

 

 

 

 

namespace Project1

{

/// <summary>

/// Summary description for WebForm1.

/// </summary>

public class xmlApp: System.Web.UI.Page

{

 

 

private void Page_Load(object sender, System.EventArgs e)

{

 

/**if(inFileLocation.Value == "")

{

btnRead.Enabled = false;

lblfileLoc.Visible = true;

}

if(inFileLocation.Value != "")

{

btnRead.Enabled = true;

lblfileLoc.Visible = false;

}

**/

lblErrors.Visible = false;

lblErrors2.Visible = false;

lblErrors3.Visible = false;

lblErrors4.Visible = false;

lblErrors5.Visible = false;

 

}

 

 

GetInt(arguments);

 

 

 

 

 

//****************************************************************

 

 

}//End of try block

 

catch(XmlException eff)

{

 

 

lblErrors4.Visible = true;

lblErrors4.Text ="File not validated"+"</br>" + eff.ToString();

}

 

catch (Exception eg)

{

lblErrors5.Visible = true;

lblErrors5.Text ="Please enter a file path"+"</br>"+ eg.ToString();

}

 

 

 

 

}//End of read method

 

/// <summary>

/// Method that is called to execute a stored procedure against the database and return a DataSet.

/// </summary>

/// <param name="aParams">A set or parameters to populate the command object.</param>

/// <returns>A dataset containing the results of the stored procedure.</returns>

///

 

 

public int GetInt(string[] aParams)

{

string sConn = GetConnString();

 

OracleConnection objConn = new OracleConnection(sConn);

OracleCommand objCmd;

 

int iResult;

 

try

{

 

PopulateCommand(aParams,out objCmd);

 

objCmd.Connection=objConn;

objConn.Open();

 

iResult = Convert.ToInt32(objCmd.ExecuteScalar().ToString());

 

}

catch (Exception ex)

{

throw ex;

}

finally

{

objConn.Close();

}

 

return iResult;

 

}

 

 

 

 

//***********************************************************************************************

private void PopulateCommand(string[] aParams,out OracleCommand objCmd)

{

objCmd = new OracleCommand();

 

objCmd.CommandType=CommandType.StoredProcedure;

 

 

OracleParameter param;

 

for (int i=0;i< aParams.Length;i++)

{

String par = aParams;

if (i==0)

{

objCmd.CommandText= aParams[0];

Response.Write("<br>"+"<br>"+"<br>"+"<br>"+"<br>"+aParams[0]);

 

 

}//End if.

 

else

{

String args = aParams;

 

param = new OracleParameter(args,OracleDbType.Varchar2);

 

param.Direction = ParameterDirection.Input;

 

param.Value = args;

 

 

 

Response.Write("<br>"+"<br>"+"<br>"+"<br>"+"<br>"+param);

 

objCmd.Parameters.Add(param);

 

}//End else.

 

}//End for loop.

 

}//End PopulateCommand method.

 

 

//*************************************************************************************************

 

 

 

}

Posted

you're probably missing some code there... you have 2 catch for no try, and your GetInt(Arguments) is not even called inside any function/proc/method

 

indent your code to see where { } begin and end, this should help you see where you missed something

Posted

I am assuming thatyou are trying to execute "COUNTROW" via a command object with Command type Stored Procedure.

 

Are you sure that COUNTROW is visible to the Connection Login as defined in your connection string? And that it has execute permissions?

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted

Permissions are fine

 

I am assuming thatyou are trying to execute "COUNTROW" via a command object with Command type Stored Procedure.

 

Are you sure that COUNTROW is visible to the Connection Login as defined in your connection string? And that it has execute permissions?

 

Well I can already execute a stored procedure using the same code, so i'm assuming that i can execute a function as well . Am I correct in assuming this

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...