2013年9月2日
摘要: 在普通情况下,我们使用SqlDataAdapter来Fill填充DataTable,如果使用下列代码我们是不能拿到主键列的:dataadapter.Fill(Table); DataColumn[]cols; cols=Table.PrimaryKey; for(inti=0;i<cols.Length;i++) { MessageBox.Show(cols[i].ColumnName); }因为数据库中的主键约束在普通情况下是不会设置到DataTable中去的。解决方法:我们可以加入一句代码,让主键约束设置到DataTable中代码:dataadapter.MissingSchemaA 阅读全文
posted @ 2013-09-02 12:21 aparche 阅读(3604) 评论(0) 推荐(0)