请教sql语句拼接的问题 - .NET技术 / C#
例如我现在在数据库中有这么几条数据:学号,姓名,班级,班主任ID,出生日期
我在查询学生信息界面中要求可以根据以上5条数据中的任意一项或多项查询出数据
我自己写的sql语句拼接如下:
C# code:
string strsql = "select * from stu where ";
if (stuNum != "")
{
strsql += "stuNum like '%" + stuNum + "%' and ";
}
else
{
strsql += "stuNum like '%%' and ";
}
if (stuName != "")
{
strsql += "stuName ='" + stuName + "' and ";
}
if (beginDate != "")
{
strsql += "createdate>=to_date('" + beginDate + " 00:00:00 " + "','yyyy-mm-dd hh24:mi:ss')" + " and ";
}
if (endDate != "")
{
strsql += "createdate<=to_date('" + endDate + " 23:59:59 " + "','yyyy-mm-dd hh24:mi:ss')" + " and ";
}
if (type != "")
{
strsql += "type ='" + type + "' and ";
}
if (consumer != "")
{
strsql += &qu
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
DataSet导出xml 批处理(循环)得怎么处理
XML文件
<A>
<B>
<C>
</C>
&nb ......
公司开发一个触摸屏程序,我负责的一块,实现这样一个功能,当鼠标点击窗口中图片(一张图分成几部分)的其中一部分时,将这部分图片截取出来,弹出新的窗口,将截取出的图片显示出来。我使用Rectange类控制了返回, ......
现在有一个部门表dept(部门名称,部门号。。)有一个人员表emp(姓名,人员编号,职位,薪资,部门)
emp表中的内容是这样的:
a 1 工程师 3000 软件部
b 2 普通员工 2000 硬件部
c 3 工程师 4000 硬件部
d ......