首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

SQL 通配符有关问题

2012-05-08 
SQL 通配符问题用VB and sQL server 做系统 下面代码是实现查询功能的输入职工号和出勤日期,即可查询到该

SQL 通配符问题
用VB and sQL server 做系统 下面代码是实现查询功能的 输入职工号和出勤日期,即可查询到该员工本天的出勤时间,精确到秒,出勤时间查询条件那里使用了通配符,但是有问题,请大神帮我改下 
If Len(Text4.Text) > 0 Then
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 员工出勤表 where 职工号='" & Trim(Text4.Text) & "' and 出勤时间 like ' " & Trim(Text5.Text) & " % ' "
Adodc1.Refresh

Else
 MsgBox ("请指定要查找人员的职工号!"), , ("提示")
End If
 PS: 输入 员工号:0001
  输入 出勤日期: 2012/5/7 (出勤日期只是LABEL的caption 值 表中为出勤时间)
  输出结果 员工号:0001 
  出勤时间: 2012/5/7 13:23:23

[解决办法]
试试这个:

VB code
Adodc1.RecordSource = "select * from 员工出勤表 where 职工号='" & Trim(Text4.Text) & "' and datediff(dd,出勤时间, cast('" & Trim(Text5.Text) & "' as datetime))=0 " 

热点排行