-
Administrator
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...
-
Junior Member
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);
-
Expert Member
Re: ODP.NET - Populating a Dataset with Multiple Data Tables
nice example thanks to guide such a simple and clear example
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules