Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pass ADO RecordSet by Value
Message
 
To
02/07/2001 12:06:33
Len Wooden
Statistical Resources, Inc
Baton Rouge, Louisiana, United States
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00525925
Message ID:
00525963
Views:
15
Tyr to declare as a property instead of a function:
Public Property GET getrset() As Recordset
>I have a compiled ActiveX EXE registered on the server computer named test05.exe.
>It contains 1 Class called Class1 with 2 functions defined as follows:
>
>Public Function getrset() As Recordset
>Dim rs2 As Recordset
>Set rs2 = New Recordset
>With rs2
> .Fields.Append "lname", adBSTR, 12
> .Fields.Append "fname", adBSTR, 12
> .CursorLocation = adUseClient
> .Open , , adOpenStatic, adLockBatchOptimistic
> .AddNew
> .Fields("lname") = "aabvbv"
> .Fields("fname") = "zzssee"
> .UpdateBatch
>End With
>Set getrset = rs2
>Set rs2 = Nothing
>End Function
>
>Public Function bob() As String
>bob = "zzzzzzzzzzzzzaaaaaa"
>End Function
>
>The test05.exe file was compiled on the server machine and the project has a reference to the msado20.tlb.
>
>
>I have copied the .vbr and .tlb files to the client computer and placed the .tlb file in the
>c:\windows\system directory, and the .vbr file in a directory called c:\coms. I then ran
>clireg32.exe on the .vbr file and set the information for the server as follows:
>
>Remote Transport = Remote Automation
>Network Address: dev-sqlserver (The name of the server computer)
>Protocol: ncacn_nb_nb
>
>I then start a new Standard EXE project on the client computer and set a reference to the test05.tlb file.
>I also set a reference to the msado20.tlb. The project has 1 form with 2 command buttons with code as follows:
>
>Private Sub Command1_Click()
>Dim rs As Recordset
>Dim xobj As object
>Set xobj = createobject("test05.class1")
>Set rs = xobj.getrset
>MsgBox rs.Fields("lname").Value
>End Sub
>
>Private Sub Command2_Click()
>Dim aa as String
>Dim xobj As object
>Set xobj = createobject("test05.class1")
>aa = xobj.bob
>MsgBox aa
>End Sub
>
>First I run the Automation Manager on the server computer. Then I run the project on the client computer and
>click the second button. I get a single connection to the server and the string is returned and displayed in
>the message box. If I click the first button I get a single connection and get the following error:
>
>
>Microsoft Visual Basic
>
>Run-time error '445':
>
>Object doesn't support this action
>
>
>If I press the Debug command button on the error box the line "Set rs = xobj.getrset" is the line in question.
>Both the server computer and the client computer have VB 6 (SP 3) installed. The server is running Win2000 Advanced
>Server and the client is running Win98 second edition. I am getting this code out of a book which tells me the
>server should send the recordset back to the client by value and allow me to sever my connection to the server and
>still have the recordset client side to work with. Is this true, and if so what am I doing wrong?
>
>Thanks in advance
> -- Martin Parker (via Len Wooden)
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Reply
Map
View

Click here to load this message in the networking platform