Results 1 to 3 of 3

Thread: ODP.NET - Populating a Dataset with Multiple Data Tables

  1. #1
    Administrator
    Join Date
    May 2006
    Answers
    331

    ODP.NET - Populating a Dataset with Multiple Data Tables

    ODP.NET - Populating a Dataset with Multiple Data TablesNow, let us add more than one data table into a dataset The following code retrieves a list of department details into a data table named Departments and another list of employee details into a data table named Employees:

    More...


  2. #2
    Junior Member
    Join Date
    May 2008
    Answers
    8

    Re: ODP.NET - Populating a Dataset with Multiple Data Tables

    Hi,
    The following code will set the two tables in one dataset.

    //Create a SqlConnection and SqlDataAdapter object
    string ConnectionString = @"User ID=sa;Initial Catalog=TimeSheet;Data Source=local;";
    SqlConnection con = new SqlConnection(ConnectionString);
    SqlDataAdapter da1 = new SqlDataAdapter("SELECT * FROM Departments",con);
    //Create a dataset to store the Project Info data.
    DataSet ds1 = new DataSet();
    da1.Fill(ds1, "Departments");
    DGrdRegTime.DataSource = ds1.Tables["Departments"];

    SqlDataAdapter da2 = new SqlDataAdapter("SELECT * FROM Emp",con);
    DataSet ds2 = new DataSet();
    da2.Fill(ds2, "Emp");
    DGrdRegTime.DataSource = ds2.Tables["Emp"];
    ds1.Merge(ds2);


  3. #3
    Expert Member
    Join Date
    Dec 2007
    Answers
    138

    Re: ODP.NET - Populating a Dataset with Multiple Data Tables

    nice example thanks to guide such a simple and clear example


  4.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact