DataSet ds = new DataSet();
DataTable table;
ds.ReadXml("c:\data.xml");
table = ds.Tables[0];//error: default type is string
table.Columns["sum"].DataType = Type.GetType("System.Int32");

解决方案 »

  1.   

    因为这个DataTable要与另一个DataTable联接,关联字段类型要匹配那么自定义表结构后还能够用readxml方法读进去么
      

  2.   

    OK 我解决了 代码放上来大家可以参考一下DataSet ds = new DataSet();DataTable table = new DataTable("table");
    table.Columns.Add("tag", typeof(String));
    table.Columns.Add("sum", typeof(Int32));ds.ReadXml("c:\data.xml");
    foreach (DataRow r in ds.Tables[0].Rows)
      allChannel.ImportRow(r);