DataSet中 新增 唯一键 外键

DataSet dsUntyped = (DataSet)Session["ds"];
   System.Data.UniqueConstraint uc = new UniqueConstraint("unqi",dsUntyped.Tables["Master"].Columns["MasterID"]);
   dsUntyped.Tables["Master"].Constraints.Add(uc);
   Session["ds"] = dsUntyped;


DataSet dsUntyped = (DataSet)Session["ds"];
   System.Data.ForeignKeyConstraint fc = new ForeignKeyConstraint("fc",dsUntyped.Tables["Master"].Columns["MasterID"],dsUntyped.Tables["Child"].Columns["MasterLink"]);
   dsUntyped.Tables["Child"].Constraints.Add(fc);
   Session["ds"] = dsUntyped;

posted @ 2006-11-10 17:23  RobotTech  阅读(229)  评论(0编辑  收藏  举报