还有
2,你如果要在dataset中加入多个表,你可
sqlDataAdapter sa=new sqlDataAdapter()
sqlCommand sc=new sqlcommand();
sa.selectcommand=sc;
sc.connection=conn;
DataSet ds=new DataSet();
sc.commandtext="select * from student"
sa.fill(Ds,"student");
sc.sc.commandtext="select * from score"
sa.fill(Ds,"score");
sc.sc.commandtext="select * from course"
sa.fill(Ds,"course");然后用
ds.tables["course"]
ds.tables["student"]
ds.tables["score"]
这样的话得到的是三个表的所有纪录,我现在想要做的是只提取一部分纪录,比如提取学号为s302010001的学生的所有信息,其中学号在student表里面,student和score中xsid分别为主键和外键score和course中kcid分别为主键和外键!!
2,你如果要在dataset中加入多个表,你可
sqlDataAdapter sa=new sqlDataAdapter()
sqlCommand sc=new sqlcommand();
sa.selectcommand=sc;
sc.connection=conn;
DataSet ds=new DataSet();
sc.commandtext="select * from student"
sa.fill(Ds,"student");
sc.sc.commandtext="select * from score"
sa.fill(Ds,"score");
sc.sc.commandtext="select * from course"
sa.fill(Ds,"course");然后用
ds.tables["course"]
ds.tables["student"]
ds.tables["score"]
这样的话得到的是三个表的所有纪录,我现在想要做的是只提取一部分纪录,比如提取学号为s302010001的学生的所有信息,其中学号在student表里面,student和score中xsid分别为主键和外键score和course中kcid分别为主键和外键!!
用条件查询可以的
select * from xsda ,pyjh where xsda.xsid=pyjh.xsid and xuehao='s302010001'
学生档案里面还有的数据项是姓名(xingming),学号(xuehao)等,培养计划里面还有的数据项为选课名称(kcmc),课程id(kcid)等
select * from xsda ,pyjh where xsda.xsid=pyjh.xsid and xuehao='s302010001'
就可以
关系有不是很复杂,干吗考虑那么多那
OR
select * from xsda,pyjh where xsda.xsid=pyjh.xsid and (xsda.xuehao='s302010001' or pyjh.xuehao='s302010001')
……
select student.*,score.*,course.* from student inner join score on score.xsid=student.xsid inner join inner on score.kcid=course.kcid
where student.xuehao='s302010001'