473,322 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Return recordset from a class.

I have this code:

Class MyClass

Private Sub Class_Initialize()
If IsEmpty(MyRecordset) Then Set MyRecordset =
Server.CreateObject("ADODB.Recordset")
End Sub

Public Function Foo
Set Foo = MyRecordset
End Function

End Class

And I call this class with code like this, using the Set keyword:

With cMyClass
Set oRs = .Foo
End With

What is going on here? Am I creating a second recordset (a copy), or am
I just passing a reference/pointer to the recordset created in he class?
Also, I have noticed that when I leave out the Set keyword, a fields
collection is returned, not a recordset. Interesting.

terje
Jul 22 '05 #1
1 4233
terje wrote:
I have this code:

Class MyClass

Private Sub Class_Initialize()
If IsEmpty(MyRecordset) Then Set MyRecordset =
Server.CreateObject("ADODB.Recordset")
End Sub

Public Function Foo
Set Foo = MyRecordset
End Function

End Class

And I call this class with code like this, using the Set keyword:

With cMyClass
Set oRs = .Foo
End With
You left out the global declaration for the MyRecordset object in your class
so the Foo function really should not really be returning a recordset, but
that's neither here nor there.

What is going on here? Am I creating a second recordset (a copy), or
am I just passing a reference/pointer to the recordset created in he
class?
All objects are passed by reference (unless they go across process
boundaries). That means that you are indeed passing a pointer to the
original recordset.

Also, I have noticed that when I leave out the Set keyword, a
fields collection is returned, not a recordset. Interesting.


Fields is the default property, so without the Set keyword, the default
property is assigned to the variable, not the object.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Adrian Parker | last post by:
Hi. I would like to query a database, given several where clauses to refine my search, and return the value of one single field in the database. eg: I have a table that lists teachers. Their...
0
by: Dot Netizen | last post by:
I am having trouble passing an ADODB.Recordset from a VB6 application to a VB.Net class library using COM Interop. I am running this on XP SP2 with the .Net Framework 1.1 and MDAC 2.8 SP1. I've...
0
by: adam | last post by:
I am getting an error when trying to use an ADODB.Recordset that was passed from a VB6 application to a VB.Net class library using COM Interop. I am running this on WinXP SP2 using the .Net...
6
by: Alan Silver | last post by:
Hello, I have an ASP that takes a connection string and SQL statement in the querystring and is supposed to return the XML representation of the recordset to the Response stream (don't worry,...
0
by: CSDunn | last post by:
Hello, In Access ADP's that connect to SQL Server databases, any time I have a situation where I have a combo box in a main form that looks up a record in a subform, the subform record source has...
1
by: lxxslay3rxxl | last post by:
Let's say I haf 3 project that I wan to list, each project should have 1 value assign to it, but if i remove 1 of the value for 1 of the project, and i tried to list all 3 projects, I get this error:...
12
by: Dooza | last post by:
I have a stored procedure that takes a number of inputs, does a bulk insert, and then outputs a recordset. When I run the stored procedure in Server Management Studio I also get a return value from...
6
by: SethM | last post by:
I have a stored procedure that returns a record set. I want to functionalize this so I can have multiple presentations of the same record set. However, I can not get rs_event.open StoreProc to pass...
3
by: fran7 | last post by:
Hi, I have this code and it works fine. I want to only display 10 results out of my database of 1000. I have tried adding the limit 10; code but get a syntax error. Where CategoryID=" & 60 & "...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.