查询:
linqDBDataContext db = new linqDBDataContext();
stu d = db.stu.Where(p => p.sid == 2).FirstOrDefault();
if (d != null)
{
var Marks = d.marks;
GridView1.DataSource = Marks;
GridView1.DataBind();
db.SubmitChanges();//提交给数据库(增,删,改都需要提交到库)
}
添加:
linqDBDataContext db = new linqDBDataContext();
stu d = db.stu.Where(p => p.sid == 2).FirstOrDefault();
if (d != null)
{
var Marks = d.marks;
//添加成绩
marks mark = new marks();
mark.score = 89;
mark.subject = "Sql";
Marks.Add(mark);
db.SubmitChanges();
//查询
GridView1.DataSource = Marks;
GridView1.DataBind();
db.SubmitChanges();//提交给数据库(增,删,改都需要提交到库)
}
如图:
未完。。。。