Problem with Datasource Class

I have a textbox whose datasource is an ADO Data Connector.  When I chance the recordset Property on the ADODC and call refresh, the contents of the textbox change to reflect the new recordset.

When I bind a textbox to a class that is a datasource, and change the contents of the class recordset, I am not able to get the contents of the textbox to change.  The first time the datasource is set for the textbox, the GetDataMember method of the class is called, but subsequent changes to the datasource don't generate calls to the GetDataMember Event.  For example, the sequence
         set t.datasource = Nothing
         Set t.Datasource = X
where x is a member of the datasource class, doesn't generate a GetDataMember event.

Can anyone help me with this one?

thanks
LVL 1
garyz31Asked:
Who is Participating?
 
p_biggelaarConnect With a Mentor Commented:
Well, using an ADODC means extra overhead, so less performance. Furthermore in this approach controls would be directly bound to the recordset so changes are applied directly to the recordset. In some cases this might be okay, while sometimes you want to be able to validate the input, or perform other actions based on specific input. If that's what you want, go for the first approach.

I'm not sure whether this is good enough for you or not. If not: let me know..
0
 
p_biggelaarCommented:
Okay, maybe there's something not quite correct with the way you deal with the event

Create an Event in your datasourceclass:

Public Event DataChanged

'Now the rest of your class's methods and properties

After you change the recordset in any way -> fire the event:

RaiseEvent DataChanged

Make sure you Declare the variable t like this:

Dim WithEvents t as YourDataClass

If you're sure you've done all this, then I'd like to take a look at your dataclass's code to see what might go wrong.

See ya...
0
 
garyz31Author Commented:
OK, I'll give that a try later today.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
garyz31Author Commented:
I'm planning to try your suggestions later today, but I wanted to check something with you first.  Are there advantages to binding a control to a datasource class object, rather than exposing a recordset as a property, linking that recordset to an ADODataConnector object, and binding the control to the ADODataConnector?

Thanks
0
 
p_biggelaarCommented:
Oops, I've not been able to check my mail for a couple of days, so I'm sorry for my late reaction.

Well there are some advantages to it as well as disadvantages. Of course having the recordset as a property and hand it over (ByRef) is easy coding. On the other hand, I use dataclasses because I want to check for validity of the data entered, want some fields to be updated based on user-entries in another one, etc... in one single class and not at every form where I use it. I personally think it's cleaner that way and furthermore it's easier to maintain your code.
0
 
garyz31Author Commented:
I appreciate that it is very useful to have the recordset, withevents in a class that takes care of all the tasks of maintaining the recordset.  However, does it actually matter by which method the recordset is bound to a control; by making the class a datasource, or exposing the recordset as a read-only property and binding it through controls through an ADO Data Connector?

Thanks
0
 
garyz31Author Commented:
I finally got the binding to work, and I thank you for that.  I'm still not convinced about the event processing advantages of the datasource class approach.  My understanding that as long as a recordset is a member of a class, it can be declared "WithEvents", whether or not the class is a datasource.  I'll be experimenting more to see if this approach makes my application operate more efficiently.

thanks
0
 
p_biggelaarCommented:
Your welcome..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.