DataSet中设置一个自增加的主键!
foreach (DataTable dt in mydataset.Tables)
{
DataColumn workColumn = dt.Columns.Add("ID", typeof(Int32));
workColumn.AutoIncrement = true;
workColumn.AutoIncrementSeed = 1;
workColumn.AutoIncrementStep = 1;
//mydataset.Tables[0].PrimaryKey = new DataColumn[] { mydataset.Tables[0].Columns[0] };
int i = dt.Columns.IndexOf(workColumn);
dt.PrimaryKey = new DataColumn[]{dt.Columns[i]};
}
为什么这样设了之后Dataset表中的ID都为空!?而且不能设置为主键
------解决方案--------------------http://blog.csdn.net/dyufei/article/details/5005313