[导入]表没有主键

http://www.hubro.net/item/868/

在执行对DATATABLE的Rows.Find(key)方法时,发生以下错误
System.Data.MissingPrimaryKeyException: 表没有主键。
官方解释如下
http://support.microsoft.com/kb/316758/zh-tw
原因是填充这个DATATABLE时,没有设置主键
解决办法,加上默认主键
myadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;


文章来源:http://wengjinbao.cn/?tid=528
posted @ 2007-11-04 20:40  海浪~~  阅读(702)  评论(0编辑  收藏  举报