1
添加表到數據集時出現問題,在調試器中觀察我將xml文件讀入數據表時看起來很好,將數據集添加到數據集表/數據集時(使用數據查看器)第一條記錄看起來很好剩餘記錄/字段包含一個紅色!標記。將表添加到數據集
fs = new FileStream(Server.MapPath(GlobalVar.compathver), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
DataTable CommentTable = new DataTable("Comment");
CommentTable.Columns.Add("ID",Type.GetType("System.Int32"));
CommentTable.Columns.Add("Author",Type.GetType("System.String"));
CommentTable.Columns.Add("Date",Type.GetType("System.String"));
CommentTable.Columns.Add("Text", Type.GetType("System.String"));
CommentTable.ReadXml(fs);
dset.Tables.Add(CommentTable);
fs.Close();
<?xml version="1.0" encoding="utf-8"?>
<CommentItems>
<Comment id="1">
<ID>1</ID>
<Author>Billy</Author>
<Date>05/22/2009</Date>
<Text>
Comments about Bills Blog.
</Text>
</Comment>
<Comment id="3">
<ID>3</ID>
<Author>Samanth</Author>
<Date>05/31/2009</Date>
<Text>
Comments about Sams Blog.
</Text>
</Comment>
<Comment id="4">
<ID>4</ID>
<Author>BillBoy</Author>
<Date>06/22/2009</Date>
<Text>
Comments about Bills Blog.
</Text>
</Comment>
<Comment id="4">
<ID>4</ID>
<Author>Bill</Author>
<Date>05/21/2009</Date>
<Text>
Comments about Lees Blog.
</Text>
</Comment>
<Comment id="3">
<ID>3</ID>
<Author>Bill</Author>
<Date>6/3/2009 2:29:54 PM</Date>
<Text>Bill's comment</Text>
</Comment>
<Comment id="4">
<ID>4</ID>
<Author>Bill</Author>
<Date>05/25/2009</Date>
<Text>
Comments about Not Not Not Bills Blog.
</Text>
</Comment>
</CommentItems>
問題在哪裏? – 2009-07-27 13:58:09