Fill dateSet from another dataSet ...in c#

Posted on 2006-05-08
Medium Priority
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

sumix earned 2000 total points
ID: 16633164
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

840 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