none
For loop RRS feed

  • Question

  • I used for loop for retrieving total records from dataset but am getting only one record ,Can u give me suggestion, where i have to change the code( See this below code)

     

                  DataRow currentRow;

                  int i = 0;

                  currentRow = dsSalesOrder.Tables[0].Rows[i];

     

          try

             {

     

     

               // foreach (DataRow currentRow in dsSalesOrder.Tables[0].Rows)

               for(i=0; i<dsSalesOrder.Tables[0].Rows.Count; i++)            

                 {

     

                  // taUpdateCreateCustomerRcd customer1 = new taUpdateCreateCustomerRcd();

                        customer1.CUSTNMBR =currentRow["Dealer #"].ToString();

                        customer1.CUSTNAME = currentRow["Dlr Name"].ToString();

                        customer1.CITY = currentRow["Dlr City"].ToString();

                        customer1.ADRSCODE = "PRIMARY";

                        // customer1.UseCustomerClass = 0;

     

                       // Create a taSopLineIvcInsert_ItemsTaSopLineIvcInsert object and populate its fields

                       // taSopLineIvcInsert_ItemsTaSopLineIvcInsert[] LineItems = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert[2];

                       // taSopLineIvcInsert_ItemsTaSopLineIvcInsert salesorder1 = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();

     

                        salesorder1.SOPTYPE = 3;

                        salesorder1.SOPNUMBE = currentRow["Invoice #"].ToString();

                        salesorder1.DOCDATE = currentRow["invoice Date"].ToString();

                        salesorder1.DOCID = "STDINV";

                        salesorder1.CUSTNMBR = currentRow["Dealer #"].ToString();

                    //taSopLineIvcInsert_ItemsTaSopLineIvcInsert salesorder2 = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();

     

                        salesorder2.SOPTYPE = 3;

                        salesorder2.SOPNUMBE = currentRow["Invoice #"].ToString();

                        salesorder2.DOCDATE = currentRow["invoice Date"].ToString();

                        salesorder2.DOCID = "STDINV";

                           LineItems[0] = salesorder1;

                        //LineItems[1] = salesorder2;

    }

     

                        // Create a eConnect SOPTransactionType schema object

                        //SOPTransactionType salesOrder = new SOPTransactionType();

     

                        // Populate the schema object with the SOP header and SOP line item objects

                        salesOrder.taUpdateCreateCustomerRcd = customer1;

                        salesOrder.taSopLineIvcInsert_Items = LineItems;

                        salesOrder.taSopHdrIvcInsert = salesHdr;

     

                        RMCustomerMasterType mastertype = new RMCustomerMasterType();

                        mastertype.taUpdateCreateCustomerRcd = customer1;

                        // mastertype.taUpdateCreateCustomerRcd = custmer2;

                        RMCustomerMasterType[] myrmcustomertype = { mastertype };

     

                        // Create an array that holds SOPTransactionType objects

                        // Populate the array with the SOPTransactionType schema object

                        SOPTransactionType[] MySopTransactionType = { salesOrder };

     

                        // Create an eConnect XML document object and populate it 

                        // with the SOPTransactionType schema object

                        eConnectType eConnect = new eConnectType();

                        eConnect.SOPTransactionType = MySopTransactionType;

     

                        XmlDocument Xmldoc = new XmlDocument();

                        // Create a file to hold the serialized eConnect XML document

                        FileStream fs = new FileStream(filename, FileMode.Create);

                        XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding());

     

                        // Serialize the eConnect document object to the file using the XmlTextWriter.

                        XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                        serializer.Serialize(writer, eConnect);

                        writer.Close();

                    }

     

     

                catch (eConnectException ex)

                {

                    Console.Write(ex.ToString());

                    Console.WriteLine("Press any key to continue . . . ");

                    Console.Read();

                }

     

     


    kavitha
    Tuesday, August 2, 2011 5:36 AM

Answers

  • Kavitha,

    You've posted to a forum for Microsoft Project, a project management scheduling product.  It looks like you may have meant to post to an Access forum?  For the complete list of forums on Technet please see:

    http://social.technet.microsoft.com/Forums/en-US/categories

    When you repost, please be more specific about what product and release you are using.

     

    Julie

    Tuesday, August 2, 2011 1:29 PM
    Moderator

All replies

  • Hi Kavitha,

    The Forum is specific to MS Project; try posting it on a relevant Forum.


    Sapna S
    Tuesday, August 2, 2011 5:59 AM
    Moderator
  • Kavitha,

    You've posted to a forum for Microsoft Project, a project management scheduling product.  It looks like you may have meant to post to an Access forum?  For the complete list of forums on Technet please see:

    http://social.technet.microsoft.com/Forums/en-US/categories

    When you repost, please be more specific about what product and release you are using.

     

    Julie

    Tuesday, August 2, 2011 1:29 PM
    Moderator