I am getting indexoutofrangeexception (see ----> pointer for the line generating the error down below in the code). The program loops through the header and line item records in a dataset tables. The tables have a relationship. My sample data has 2 headers, each with 2 lines. The progam has two loops, the first one loops through the header records and the second one loops through the child records of the header. 

Part of the program:

```
     // ***** PO Header and Line 

        int ln;
        ln = 0;

        // Create an eConnect PO Header node object
        taGLTransactionHeaderInsert jeh = new taGLTransactionHeaderInsert();

        // Create an array for lineitems
        taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert[] lineitems = new   taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert[ln];

        foreach (DataRow dtrHDR in ds.Tables["Header"].Rows)

        {
            Array.Clear(lineitems, 0, ln);

            jeh.BACHNUMB = "Sheraz";
            jeh.JRNENTRY = jenoint;
            jeh.REFRENCE = dtrHDR["Reference"].ToString();
            jeh.SOURCDOC = dtrHDR["AvantisJE"].ToString();
            jeh.USERID = System.Environment.UserName;
            jeh.TRXDATE = System.DateTime.Now.ToString();

            ln = 0;

            foreach (DataRow dtrLine in dtrHDR.GetChildRows("HdrLine"))

            {

                // Populate the elements of the taPoLIne_ItemsTaPOLine XML node
                taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert jel = new taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert();

                jel.BACHNUMB = jeh.BACHNUMB;
                jel.JRNENTRY = jeh.JRNENTRY;
                jel.ACTNUMST = dtrLine["GreatPlains"].ToString();
                jel.DEBITAMT = Convert.ToDecimal(dtrLine["Debit"].ToString());

                //Avantis Inv Trx Key
                jel.ORDOCNUM = dtrLine["AvantisJE_Line"].ToString();
                // Avantis GL Trx Type
                jel.ORTRXDESC = dtrLine["transactiontypename"].ToString();

                //Add POLine to an Array
                lineitems[ln] = jel;     ----------------> I get an error here!

                ln = ln + 1;

                Array.Resize(ref lineitems, ln + 1);

            }

        }

```