I fill the data set twice,
the table name never set correctly.
I see only one table in the DataSet
What is chances?
public static DataSet GetSchoolTree()
{
BLLBase.CreateConnection();
BLLBase.Connection.Open();
DataSet dataSet = new DataSet("SS");
Stages.GetStages(ref dataSet);
Schools.GetSchools(ref dataSet);
BLLBase.Connection.Close();
dataSet.Relations.Add(dataSet.Tables["Schools"].Columns["ID"], dataSet.Tables["dbo.Stages"].Columns["School_ID"]);
return dataSet;
}
internal static void GetSchools(ref DataSet dataSet)
{
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.TableMappings.Add("dbo.Schools", "Schools");
SqlCommand command = new SqlCommand();
command.CommandText = "[dbo].[SR_School_ALL]";
command.CommandType = System.Data.CommandType.StoredProcedure;
command.Connection = BLLBase.Connection;
adapter.SelectCommand = command;
adapter.Fill(dataSet);
}
internal static void GetStages(ref DataSet dataSet)
{
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.TableMappings.Add("dbo.Stages", "Stages");
SqlCommand command = new SqlCommand();
command.CommandText = "[dbo].[Stp_Stages_All]";
command.CommandType = System.Data.CommandType.StoredProcedure;
command.Connection = BLLBase.Connection;
adapter.SelectCommand = command;
adapter.Fill(dataSet);
}
thanks
Calling .Fill() on a dataset will re-load it, not load new results into a different table. Instead, call .Fill() on a table within the dataset. You might want to try something like this: