Fill dateSet from another dataSet c#

Posted on 2006-05-08
Last Modified: 2010-08-05

hello experts ..

in my project in c# i make a connection to DB ok
and i added 2 data set from tool bar
the DataSet1 contain the table "transactionTable" with fields :
empID, attendanceTime, LeaveTime, Date, Day

and Dataset2  contain view "table" called "ccc" with fields :
attendanceTime, LeaveTime, Date, Day

i want to take some of DataSet1 rows and put it in the new Dataset "Dataset2"

i am trying to write the following code in c# :
int ID = 1000;
int monthNum = 4;
HijriCalendar hijriCalendar = new  HijriCalendar();

this.oleDbDataAdapter1.SelectCommand.CommandText = "SELECT * FROM transactionTable WHERE empl_ID = " + ID.ToString();
DataTable dt1 = this.dataSet11.Tables["transactionTable"];

      Dataset2 ds2 = new Dataset2();
      DataTable dt2 =  ds2.Tables[0];

      for(int i = 0; i < dt1.Rows.Count ; i++)            
      DateTime todayDateField = Convert.ToDateTime(dt1.Rows[i][1]); //dt1.Rows[i][1] is date field in the transactionTable
            if(hijriCalendar.GetMonth(todayDateField) == monthNum)
                  //here add this row  dt1.Rows[i][1] to the dataTable that is in the new dataSet "Dataset2"
}//end of for loop

//here return the new dataSet "Dataset2"..

anyone help me to complete this code ..??
i hope u undersatnd me , and ask me plez if u need some iformation to clear the question ..

the second dataset is exist in the project ...only  i want to fill it with some date from the first dataSet  
Question by:dede11
    1 Comment
    LVL 12

    Accepted Solution

    you can add a row in dt2 with

              dt2.Rows.Add(new object[] {  dt1.Rows[i]["attendanceTime"],
                                                          dt1.Rows[i][" Date"],
                                                          dt1.Rows[i]["Day"] } );

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now