如何用函数来实现数据库查询结果的返回,及其调用,请高人指点
function data()
rs.open "select id,name sex from mytable",conn
data=?
end function
把查询结果通过函数返回,以及如何调用它
[解决办法]
----------------------------------------
Dim conn As New ADODB.Connection, rs As New ADODB.Recordset
Private Function data() As String
rs.Open "select id,[name],sex from mytable", conn
data = rs!id & "-" & rs!name & "-" & rs.sex
rs.Close
End Function
Private Command1_Click()
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;"
MsgBox data
Set rs = Nothing
conn.Close
Set conn = Noting
End Sub
[解决办法]
function data()as adodb.recordset
dim rs as new adodb.recordset
rs.cursorlocation=aduseclient
rs.open "select id,name sex from mytable",conn
set data=rs
end function
调用
command1_clock
dim rs as adodb,recordset
set rs=data
end sub
[解决办法]
两楼的RS怎么现实出来,用文本框报数据类型不对