Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a recordset object be passed from a component to client

Status
Not open for further replies.

Shuchi

Programmer
Jan 10, 2002
29
GB
Hi,
I want to execute a query thru MTS component from vb client.
But i want to get the whole recordset object from the component
How can i do it?

Thanx and regards,
Shuchi
 
no problem,

write a function in the mts class that gets a recordset by refferance. do the query, and at the end set the recordset activeconnection to nothing (it becumes a disconected recordset, and then you can pass it)

example:

public sub dosmething (rs as recordset)
sql="select * from tsble"
rs.open sql,myconnection
set rs.activeconnection=nothing
end sub
 
Zeevgetner is very close to the actual solution. I would suggest a few changes. Rather than passing a recrdset reference up to the server (I.E. More data to marshal), create the recordset in the server component and return it from a function. Also, make sure that the server is set to be a client side cursor and not a server side cursor (the default).
Finally, this will only work if you are using ADO. If you are using DAO recordsets, they will not marshal.
Here is some sample code for the Server Component . . .


Code:
Public Function GetMyData() As ADODB.Recordset

   Dim artData As ADODB.Recordset
   Dim strSQL As String
   Dim strConnection As String
   
   
   strSQL = "select * from tsble"
   strConnection = "Your Connection String"
   
   Set artData = New ADODB.Recordset
   With artData
      .CursorLocation = adUseClient
      .Openopen strSQL, strConnection
      Set .ActiveConnection = Nothing
   End With

   Set GetMyData = artData


End Function

And then from your client application

Code:
Dim obj As MyLib.MyClass
Dim artData as ADODB.Recordset

Set obj = CreateObject("MyLib.MyClass")
set artData = obj.GetMyData
Set obj = Nothing
- Jeff Marler B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top