| 发表于:2007-04-09 08:51:04 楼主 |
设计一往access中存储图片的程序,现想对这数据库通过 "员工编号 "或 "员工姓名 "字段查询图片值,运行不过,请帮忙,谢谢了! private sub command1_click() dim strsql as string strsql = "select * from 员工照片 where " '//给定义好的字符变量赋予sql语句 '//判断复选框有一个选中时,则 if chkcode.value = 1 or chkname.value = 1 then '//判断二个复选框同时选中时,则 if chkcode.value = 1 and chkname.value = 1 then strsql = strsql & "员工编号= ' " & trim(textnumber.text) & " ' " & "and " & " 员工姓名 = ' " & trim(textname.text) & " ' " '//判断编号与进入公司时间复选框选中时,则 if chkcode.value = 1 then '//只有编号复选框选中时,则 strsql = strsql & "员工编号= ' " & trim(textnumber.text) & " ' " end if if chkname.value = 1 then '//只有姓名复选框选中时,则 strsql = strsql & " 员工姓名 = ' " & trim(textname.text) & " ' " end if end if if rstqueryphoto.state = adstateclosed then rstqueryphoto.open strsql, dbcon, adopenkeyset, adlockoptimistic, adcmdtext//当其中一复选框选中再点击查询按钮时,次句被提示错误3709,连接无法用于此操作,在此上下文中可能被关闭或删除. end if set imgpreview.datasource = rsphoto.datasource imgpreview.refresh '//刷新网格 rsphoto.close '//关闭记录集 textnumber.text = empty '//请空文本框 textname.text = empty rsphoto.close '//关闭记录集 textnumber.text = empty '//请空文本框 textname.text = empty else if rsqueryphoto.state = adstateclosed then rsqueryphoto.open "员工照片 ", dbcon, adopenkeyset, adlockoptimistic, adcmdtable//当复选框没有选中再点击查询按钮时,次句也被提示错误3709,连接无法用于此操作,在此上下文中可能被关闭或删除. end if set imgpreview.datasource = rsphoto.datasource end if end sub |
|
|
|
|