pro_vb thread: Passing large amounts of data between classes.
> hi David,
>
> You can accomplish this by using the DataBinding Collection. Here,
> you will create a class which will act as a DataSource and you can
> 'bind' the data you have in the class(in your case it is from Oracle) to
> any controls in the UI, without passing the Data at all to the UI. Your
> UI will be the Data Consumer.
>
> This what you have to do....
>
> 1. Do the following in your Class Module
>
> a) Set the DataSourceBehaviour property of the class to vbDataSource.
> Once you do that, another event will be added to your Class module. This
> would be the GetDataMember event, which fires every time when the Data
> Consumer wants any data.
>
> b) Your Recordset declaration should include the keyword, WithEvents.
> (Ex. Dim WithEvents rs as ADODB.Recordset)
>
> c) Then, asusual, populate the Recordset from your table in the
> Back-End.
>
> d) In the GetDataMember Event, write the following one line code...
>
> Set Data =3D rs '(Data will be a parameter of the event, rs is your
> recordset)
>
> e) Add two procedures in your class module
>
> Public Sub MoveNext()
> rs.MoveNext
> If rs.EOF then rs.MoveLast
> End Sub
>
> Public Sub MovePrevious()
> rs.MovePrevious
> If rs.BOF then rs.MoveFirst
> End Sub
>
> f) That finishes the class module and 50% of our work. Now, turn your
> attention to the UI
>
> 2. The following are to be done in your Form.
>
> a) Choose Project - References Menu and select the Microsoft DataBinding
> Collection
>
> b) Have two textboxes (or number of controls depending upon the data you
> get...) and have 2 CommandButtons (for our example)
>
> c) Write the following code in the General section of the form
>
> Dim cl as New Class1 'the name of the class created above
> Dim bind as New BindingCollection 'this will bind the data in
> the Class Module
>
> d) In the Form_Load Event write the following Code....
>
> Set bind.DataSource =3D cl 'set the Datasource to the instance of
> the class.....
>
> bind.Add Text1,"Text","<FIELDNAME IN THE rs>" 'comments below
> bind.Add Text2,"Text","<FIELDNAME IN THE rs>" 'comments below
>
> 'the parameters for the Add Method are the Name of the control to
> bind, the property of the control that holds the data - The Text
> property of the textbox control and the exact fieldname that the
> recordset object in the class module has (normally it would be the
> fieldname of the table itself)
>
>
> e) In Command1_Click Event write the following code.
>
> cl.MovePrevious
>
> d) In the Command2_Click Event write the following code
>
> cl.MoveNext
>
>
> 3. Run the Form. Click on the Command Buttons. You can see that the
> value in the TextBoxes changes to reflect the Data in the Recordset of
> the Class Module..... And you don't have a single "Data Access" code in
> the UI at all!!!
>
> I think this would have given you a fair idea about DataBinding
> Collection and its use... Hope this would be usable for your
> architecture too.......
>
> Thanks,
>
> N.T.GOPALAKRISHNAN
Thank you for you reply. I am currently tring the process you defined. I
need to spill the data into a grid. Is there away to load the grid with
out having to loop through all of the records?
Thank you,
David