yes ,the technical things are based on the OracleConnection,OracleCommand,OracleDataAdapter,
but here I don't care the detailed technical things,here is my Solution about how to construct the DataSet,
and welcome everyone can give some comments
1. to get the columnheader split by ';' ,then store the column header to an string array
2. because the foreign key constraint, we can get the corresponding data,after that, split by ';'
3. give a loop in data content row using the variable from 1 to content.rows.count;
4. construct DataRow variable then insert the variable into DataSet
5. return the DataSet
public DataSet constructionDataSet(int kpi_lookup_id)
{
DataSet customDs = new DataSet("kpi_lookup");
DataTable customDt = customDs.Tables.Add("kpi");
string strColumnHeader = this.getColumnHeader(kpi_lookup_id);
string[] strListArray = this.getArrayViaString(strColumnHeader);
int ii = 0;
foreach (string m in strListArray)
{
customDt.Columns.Add(m, typeof(string));
ii = ii + 1;
}
DataSet ds = this.GetKPIContent(kpi_lookup_id);
foreach (DataRow dr in ds.Tables[0].Rows)
{
string[] contentArray = dr.ItemArray[0].ToString().Split(';');
DataRow newCustomersRow = customDs.Tables["kpi"].NewRow();
for (int j = 0; j < contentArray.Length; j++)
{
newCustomersRow[j] = contentArray[j];
}
customDt.Rows.Add(newCustomersRow);
}
return customDs;
}
======================================================================================
three function events are below:
public string getColumnHeader(int kpi_lookup_id)
{
string strSql = @"select 'ID'||columnheader AS columnheader
from kpi_lookup where id = " + kpi_lookup_id;
string strColumnHeader;
OracleConnection conn = this.DBCon();
conn.Open();
OracleDataAdapter oda = new OracleDataAdapter(strSql, conn);
DataSet ds = new DataSet();
oda.Fill(ds);
strColumnHeader = ds.Tables[0].Rows[0][0].ToString();
ds.Dispose();
return strColumnHeader;
}
public string[] getArrayViaString(string columnHeader)
{
string[] strArrayColumnHeaderList = columnHeader.Split(';');
return strArrayColumnHeaderList;
}
public DataSet GetKPIContent(string sqlText)
{
OracleConnection conn = DBCon();
conn.Open();
OracleDataAdapter oda = new OracleDataAdapter(sqlText, conn);
DataSet ds = new DataSet();
oda.Fill(ds);
conn.Close();
return ds;
}
public DataSet GetKPIContent(int kpi_lookup_id)
{
string strSql = "select id||content as content from
kpi_lookup_detail where kpi_lookup_id ="+kpi_lookup_id +" order by id";
DataSet ds = this.GetKPIContent(strSql);
return ds;
}