Solved

Problem with Datasource Class

Posted on 2000-04-09
8
305 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

786 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