统计“一班”的学生个数
2014-10-25 16:27:47 访问(2304) 赞(0) 踩(0)
-
提示:
UTB_EXAM_STUDENT (学生表)
UTB_EXAM_CLASS(班级表)
的连表操作
-
select
count(s.ID) as '学生个数'
from
UTB_EXAM_STUDENT s, UTB_EXAM_CLASS c
where
s.ClassId = c.ID and c.TheName = '一班'
-
/// <summary>
///
/// </summary>
/// <param name="xdbHelper"></param>
protected void DataBindTheContorls(DBHelper xdbHelper)
{
string theResult=null;
bool bIsCreate = true;
if (xdbHelper == null)
{
xdbHelper = SlowX.DAL.Helpers.DBHelper.CreateDBHelper();
}
else
{
// 没有打开链接 //
bIsCreate = xdbHelper.IsNotOpen();
}
try
{
if (bIsCreate)
xdbHelper.OpenDBHelper();
SlowX.ExamLib.Business.UTB_EXAM_STUDENT
bll
=
SlowX.ExamLib.Business.UTB_EXAM_STUDENT.instance;
SlowX.ExamLib.Entity.UTB_EXAM_STUDENT
entity
=
new SlowX.ExamLib.Entity.UTB_EXAM_STUDENT();
SlowX.ExamLib.Entity.UTB_EXAM_CLASS
entityClass
=
new SlowX.ExamLib.Entity.UTB_EXAM_CLASS();
IFromTableDriver ifrom = entity;
ifrom.AddIFromTableItemWithBaseEntity("tClass", entityClass);
IQueryDriver iq = entity;
iq.AddIQueryItemWithEntityFieldInfo(entity._ClassId, entityClass._ID);
iq.AddIQueryItemWithEntityFieldInfo(entityClass._TheName, "一班");
ISelectDriver iselect = entity;
iselect.AddISelectItemWithEntityFieldInfo
(
entity._ID
);
theResult = bll.Count(entity, xdbHelper).ToString();
if (bIsCreate)
xdbHelper.EndDBHelper();
}
catch (Exception err)
{
if (bIsCreate)
xdbHelper.TranDBHelper();
throw err;
}
finally
{
if (bIsCreate)
xdbHelper.FinallyDBHelper();
}
strResult = theResult;
}
select count(1) from UTB_EXAM_STUDENT t ,
UTB_EXAM_CLASS tClass where t.ClassId = tClass.ID and tClass.TheName = '一班'
@tClassp1 = '一班'
select count(1) from UTB_EXAM_STUDENT t ,
UTB_EXAM_CLASS tClass where t.ClassId = tClass.ID and tClass.TheName = @tClassp1
@tClassp1 一班 String Input SqlParameter
上一条:
下一条:
相关评论
发表评论