06-24-2009, 02:02 PM
Hi, I found a solution for the problem. The following code works for me.
*******************
*********************
Here I have declared the connection object and recordset object globally (above the function). I have also used Set keyword infront of the function call (Set RdSt=getrs).
Revert back with your thoughts on the above code.
Thanks,
*******************
Code:
Set conn=createobject("adodb.connection")
Set rec_set=createobject("adodb.recordset")
function getrs()
str_con= "dsn=dsn name"
conn.open str_con, "username", "password"
rec_set.open "select * from table", conn, 2, 3
Set getrs = rec_set
End Function
Set RdSt = getrs
RdSt.movefirst
msgbox(RdSt(0))
rec_set.close
conn.close
Set RdSt = Nothing
Here I have declared the connection object and recordset object globally (above the function). I have also used Set keyword infront of the function call (Set RdSt=getrs).
Revert back with your thoughts on the above code.
Thanks,