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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with loading up data from thru class

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hi:

i've been trying to learn how to encapsulate the db and I'm trying to use classes.

How do I load data up if I need to loop through the recordset?

How would I write one of the Subs for it?

Thanks

noviceclassbuilder
 
Your question is a little vague but it sounds like all you have to do is create the code to manipulate the database but put it in a class. You can create a function or property in a class of a certain database type. For example:

Function StudentTable as Adodb.Recordset

or

property Get StudentTable(Row) as Adodb.Recordset

or

Function GetRecordData(Rec as adodb.recordset)

You can also pass recordsets between modules, classes, and procedures, therefore allowing you to loop through a recordset from a class or anything you want.
 
Thank you for responding - since I'm pretty new to vb I still have problems describing what i'm trying to do. Here is what I need to do.

I'm trying to populate a control with data from the class.
I was doing it this way before

with adorec
Do Until adorec.eof
addtocontrol (!name, !age, !ss#)
.movenext
Loop
End with

Now in my class

I have all the lets and gets and variable declarations. I have the class_initialize which does the connection. I have the Init which does the recordset sql statement and I place all the member variables to db fields.

Now how do I do what I was trying to do above using one of the functions that you gave?

Does that make sense?

Thanks for your help
 
Question:

Do I have a function in my class that is like

Function MoveNext(Recordset) As Recordset

Recordset.Movenext

End Function

Will that work?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top