DataSet _myDataSet = new DataSet();//存有11张DataTable
public DataTable JudgeDataIsByte(int SeleteItem)
{
DataTable table = _myDataSet.Tables[SeleteItem];
DataTable newTable = null;
try
{
newTable = table.Clone();//克隆表结构
newTable.Columns["GUID"].DataType = typeof(string);//改变 GUID数据类型
foreach (DataRow tabRow in table.Rows)
{
foreach (DataColumn tabCol in table.Columns)
{
string str = "";
if (tabCol.DataType == typeof(byte[]))
{
byte[] guid = (byte[])tabRow[tabCol];
//循环将十六进制转为string
for (int i = 0; i < guid.Length; i++)
{
str += guid[i].ToString("X2");
}
}
}
newTable.ImportRow(tabRow);//将Table中的数据复制到newTable中
//这里该怎么写,请教。
//问题:newTable 有了数据后,要将循环得到的 str 赋值给每一行的 GUID,
//最后返回newTable
//注:每一行的 str 是不相同的
}
}
catch { }
return newTable;
}
public DataTable JudgeDataIsByte(int SeleteItem)
{
DataTable table = _myDataSet.Tables[SeleteItem];
DataTable newTable = null;
try
{
newTable = table.Clone();//克隆表结构
newTable.Columns["GUID"].DataType = typeof(string);//改变 GUID数据类型
foreach (DataRow tabRow in table.Rows)
{
foreach (DataColumn tabCol in table.Columns)
{
string str = "";
if (tabCol.DataType == typeof(byte[]))
{
byte[] guid = (byte[])tabRow[tabCol];
//循环将十六进制转为string
for (int i = 0; i < guid.Length; i++)
{
str += guid[i].ToString("X2");
}
}
}
newTable.ImportRow(tabRow);//将Table中的数据复制到newTable中
//这里该怎么写,请教。
//问题:newTable 有了数据后,要将循环得到的 str 赋值给每一行的 GUID,
//最后返回newTable
//注:每一行的 str 是不相同的
}
}
catch { }
return newTable;
}
DataRow row = newTable.NewRow();
row["GUID"] = str;
newTable.row.Add(row);
public DataTable JudgeDataIsByte(int SeleteItem)
{
DataTable table = _myDataSet.Tables[SeleteItem];
DataTable newTable = null;
try
{
newTable = table.Clone();//克隆表结构
newTable.Columns["GUID"].DataType = typeof(string);//改变 GUID数据类型
foreach (DataRow tabRow in table.Rows)
{
string str = "";
foreach (DataColumn tabCol in table.Columns)
{
if (tabCol.DataType == typeof(byte[]))
{
byte[] guid = (byte[])tabRow[tabCol];
//循环将十六进制转为string
for (int i = 0; i < guid.Length; i++)
{
str += guid[i].ToString("X2");
}
}
}
newTable.ImportRow(tabRow);//将Table中的数据复制到newTable中
newTable.Rows[0]["GUID"] = str;
//这里该怎么写,请教。
//问题:newTable 有了数据后,要将循环得到的 str 赋值给每一行的 GUID,
//最后返回newTable
//注:每一行的 str 是不相同的
}
}
catch { }
return newTable; }