Solved

Problem with Datasource Class

Posted on 2000-04-09
8
296 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now