Link to home
Start Free TrialLog in
Avatar of cyimxtck
cyimxtckFlag for United States of America

asked on

C# VS2010 array passing to a calling method

The below code seems really straight forward but the method providing the stored procedure array of parameters (ArrayParm) isn't being read correctly by the calling method(rbInsert_Click)

        private void rbInsert_Click(object sender, RoutedEventArgs e)
            String conn = Connections.BaseConnection;
            DatabaseFunction.ExecuteStoredProcInsert(conn, OracleObjects.InsertConnection, ArrayParm());  // it is telling me that the ArrayParm() is an invalid argument.

// the above method uses a connection, a procedure name and the array of procedure //parameters but I cannot see to get it to call the other method (won't compile)

        public StoredProcParameter[] ArrayParm()  // <-- no problems here, it all seems good
            StoredProcParameter[] oPL = new StoredProcParameter[6];

            oPL[0] = DatabaseFunction.CreateParameter("i_DBName", tbxDBName.Text, OracleDbType.Varchar2);
            oPL[1] = DatabaseFunction.CreateParameter("i_DBType", cboDBType.SelectedItem, OracleDbType.Varchar2);
            oPL[2] = DatabaseFunction.CreateParameter("i_UserName", tbxUID.Text, OracleDbType.Varchar2);
            oPL[3] = DatabaseFunction.CreateParameter("i_PWD", tbxDBName.Text, OracleDbType.Varchar2);
            oPL[4] = DatabaseFunction.CreateParameter("i_INSTANCE", cboInstance.SelectedItem , OracleDbType.Varchar2);
            oPL[5] = DatabaseFunction.CreateParameter("i_MAIN", tbxMain.Text, OracleDbType.Varchar2);
            return oPL;

Any thoughts would be greatly appreciated.


Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

in your main what if you did this:

 StoredProcParameter[] oPL = ArrayParm();

set a breakpoint on the line and see if you can get it to run?  What happens when you try to compile, what error is it giving you?
Avatar of cyimxtck


After adding this line:

        public StoredProcParameter[] ArrayParm()
            StoredProcParameter[] oPL = ArrayParm();

It won't compile on this line (still but different error):

DatabaseFunction.ExecuteStoredProcInsert(conn, OracleObjects.InsertConnection, ArrayParm());

it says "Argument 3 must be passed with the ref keyword"

So after doing this:

DatabaseFunction.ExecuteStoredProcInsert(conn, OracleObjects.InsertConnection, ref ArrayParm());

it chokes on just this, not the whole line:

, ref ArrayParm());

saying "a ref or out argument must be assigned a variable"

anything come to mind?
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
StoredProcParameter[] oPL = ref ArrayParm();

this throws

"invalid expression term 'ref' "

and ; expected for ArrayParm()
I got it now; nevermind.  Just took a fresh head but I will still award the points for the effort