|
-
Aug 25th, 2000, 01:13 AM
#1
Thread Starter
Lively Member
Can I return a Recordset from a DLL called by my EXE?
My DLL does all DB access and I would like to return an actual recordset in some cases to easily populate a grid with the RS information.
I get an error when I do as follows:
*****************************************************
Command_Click
*****************************************************
Dim objCase As LBCom2.Case
Set objCase = CreateObject("LBCom2.Case")
Dim objRS As ADODB.Recordset
Set objRS = CreateObject("ADODB.Recordset")
objRS.ActiveConnection = Nothing
Set objRS = objCase.GetCases
Do While Not objRS.EOF
..... Grid Code Here
Loop
*****************************************************
The GetCases Function Returns a Recordset, but I get and error trying to access the RS within the EXE.
Error 3704-Operation not allowed when the object is closed.
I don't have a connection to open it with....
What can I do???
Thanks!
Kevin
-
Aug 25th, 2000, 02:13 AM
#2
Hyperactive Member
Not sure if you can pass a recordset from a dll (I'm not sure if VB allows it, if it doesn't you can just return it as Object). But you don't need to do a createobject first, this is enough:
Dim rs As ADODB.Recordset
Set rs = Class.Function
With createobject you create a new instance of the recordset; which you don't want, you want to have a reference to the recordset created in the class.
But I believe M$ says that it's not smart to pass object around from a dll to an exe, so f it fails, you can also let the function return the SQL Query, and open the recordset in your exe.
-
Aug 25th, 2000, 03:39 AM
#3
New Member
Yes you can! you need to use disconnected recordsets.
"dim myrs as ADOR.recordset"
Just make your function return a recordset i.e.
function Myfunction() as ador.recordset
dim tempdb as adodb.recordset
etc
.
.
open connection to database
set myfunction = tempdb
end function
in your EXE just declare a ADOR.recordset
and the following code
"Set myrs = myfuction"
Remember this is a disconnected recordset so won`t see changes made to the database etc.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|