if rst.state=adstateopen then rst.close
rst.open sql,connect,adopenkeyset,adlockreadonly
if rst.recordcount>0 then
consult=rst.fields(0).value &""
end if
rst.open sql,connect,adopenkeyset,adlockreadonly
if rst.recordcount>0 then
consult=rst.fields(0).value &""
end if
rst.open sql,connect,adopenkeyset,adlockreadonly
if rst.recordcount>0 then
consult=rst.fields(0).value &""
end if
还是不行啦!和刚才一个样,它提示说类型不匹配不能够对未打开的对象进行操作!谢谢你啦!
Public Function consult(rst As adodb.Recordset, sql As String) As String
第一个参数干脆不要,反正你要在这个function里重新open的public function consult(sql as string) as string
dim rst as new adodb.recordsetrst.open sql,connect,adlockreadonlyif rst.recordcount>0 then
consult=rst.fields(0).value & ""
end if
set rst=nothing
end function