Hello!
I just picked up C# about 3 weeks ago and now I am trying to bind 6 different database tables to one dataset. Is this possible? I've tried several variations of the same code, but I am having the same trouble. The code compiles with no problems, but when I click to to display the datagrid on the ASP.Net webpage, everything shows but the datagrid. It just disappears. Can someone please look at my code and tell me what I'm doing wrong, it will be greatly appreciated:
...
private void BindDGrdRegTime()
{
//Create a SqlConnection and SqlDataAdapter object
string ConnectionString = @"User ID=sa;Initial Catalog=TimeSheet;Data Source=local;";
SqlConnection cnn = new SqlConnection(ConnectionString);
SqlDataAdapter da1 = new SqlDataAdapter("SELECT * FROM Account",con);
//Create a dataset to store the Project Info data.
DataSet ds1 = new DataSet();
da1.Fill(ds1, "Account");
DGrdRegTime.DataSource = ds1.Tables["Account"];
SqlDataAdapter da2 = new SqlDataAdapter("SELECT * FROM Emp",con);
DataSet ds2 = new DataSet();
da2.Fill(ds2, "Emp");
DGrdRegTime.DataSource = ds2.Tables["Emp"];
SqlDataAdapter da3 = new SqlDataAdapter("SELECT * FROM Project",con);
DataSet ds3 = new DataSet();
da3.Fill(ds3, "Project");
DGrdRegTime.DataSource = ds3.Tables["Project"];
SqlDataAdapter da4 = new SqlDataAdapter("SELECT * FROM Hrs",con);
DataSet ds4 = new DataSet();
da4.Fill(ds4, "Hrs");
DGrdRegTime.DataSource = ds4.Tables["Hrs"];
SqlDataAdapter da5 = new SqlDataAdapter("SELECT * FROM DayOfWk",con);
DataSet ds5 = new DataSet();
da5.Fill(ds5, "DayOfWk");
DGrdRegTime.DataSource = ds5.Tables["DayOfWk"];
SqlDataAdapter da6 = new SqlDataAdapter("SELECT * FROM Group",con);
DataSet ds6 = new DataSet();
da6.Fill(ds6, "Group");
DGrdRegTime.DataSource = ds6.Tables["Group"];
ds1.Merge(ds2);
ds1.Merge(ds3);
ds1.Merge(ds4);
ds1.Merge(ds5);
ds1.Merge(ds6);
}
...
*******(*)*******