Avatar of cyimxtck
Flag 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.


C#.NET Programming

Avatar of undefined
Last Comment

8/22/2022 - Mon
Kyle Abrahams

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?

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?
Kyle Abrahams

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

StoredProcParameter[] oPL = ref ArrayParm();

this throws

"invalid expression term 'ref' "

and ; expected for ArrayParm()
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy

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