Solved

Problem with Datasource Class

Posted on 2000-04-09
8
306 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:garyz31
  • 4
  • 4
8 Comments
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2703719
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
 
LVL 1

Author Comment

by:garyz31
ID: 2704720
OK, I'll give that a try later today.
0
 
LVL 1

Author Comment

by:garyz31
ID: 2705263
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2711392
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
 
LVL 1

Author Comment

by:garyz31
ID: 2712303
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
 
LVL 2

Accepted Solution

by:
p_biggelaar earned 75 total points
ID: 2715229
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
 
LVL 1

Author Comment

by:garyz31
ID: 2718304
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
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2718752
Your welcome..
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question