DataTable dt = new DataTable();
string[] TableName = ds.Tables[0].Rows[i]["CONTENT"].ToString().Split(';');
int h=0;
DataRow dr = dt.NewRow();
dr = dt.NewRow();
while (h < TableName.Length)
{
dr[h] = TableName[h].ToString();
h++;
}
dt.Rows.Add(dr);
例子:
public static DataTable Convert(DataSet ds ,DataSet col)
{
DataTable dt = new DataTable();
if (ds.Tables[0].Rows.Count > 0&&col.Tables[0].Rows.Count>0)
{
for (int h = 0; h < col.Tables[0].Rows.Count; h++)
{
dt.Columns.Add(col.Tables[0].Rows[h][0].ToString(), typeof(string));
}
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string[] TableName = ds.Tables[0].Rows[i]["CONTENT"].ToString().Split(';');
int h=0;
DataRow dr = dt.NewRow();
dr = dt.NewRow();
while (h < TableName.Length)
{
dr[h] = TableName[h].ToString();
h++;
}
dt.Rows.Add(dr);
}
}
return dt;
}