+ -
当前位置:首页 → 问答吧 → 求教 关于数据库查询的问题

求教 关于数据库查询的问题

时间:2011-12-09

来源:互联网

想要按学号查询数据库中是否包含该数据项 返回bool值 该怎么操作啊


顺便问下
strSQL1="select * from student where code = studentid";
strSQL2.Format("select * from outgrade where code = %s",studentid);
strSQL的值有什么不同啊

作者: continue23456   发布时间: 2011-12-09

if exist .....

作者: ouyh12345   发布时间: 2011-12-09

顺便问下
strSQL1="select * from student where code = studentid";
strSQL2.Format("select * from outgrade where code = %s",studentid);
strSQL的值有什么不同啊 

但从这两句话,没什么区别
第一句是写死了,以后要改变studentid很困难
第二句则可以从参数里传studentid

作者: ouyh12345   发布时间: 2011-12-09

可以通过查询返回的条目处理,如果是0 就没有值


顺便问下
strSQL1="select * from student where code = studentid";
strSQL2.Format("select * from outgrade where code = %s",studentid);
strSQL的值有什么不同啊 

第一句输出为:select * from student where code = studentid  
第二句输出为:select * from outgrade where code = studentid变量的值

作者: glovel0425   发布时间: 2011-12-09

"select count(id)as num from student where code =%s",studentid"
GetCollection(num);

这个语句中 num 是 整型还是 Cstring 类型
返回的是 符合条件的id 的个数 ???????

m_pDatabase-> ExecuteSQL(strSQL); 执行数据库有什么作用 啊 看到有些代码有加有些没加

作者: continue23456   发布时间: 2011-12-10

热门下载

更多