Link to home
Start Free TrialLog in
Avatar of DreamingEagle
DreamingEagle

asked on

BOUND VS. UNBOUND CONTROLS

For years have shied away from bound controls using DAO and ADO simply because I liked the control this method gives a programmer.  You read the data into memvars, let the user edit the memvars, validate the memvars, and, once everything is valid, write the changes back to the record.  

But in working through Wayne Freeze's "SQL Server 7 With VB 6"---in which he used strictly bound controls---I began asking myself how much of unbound methodology is tradition (i.e., "real programmers don't use bound controls") and how much of it really makes sense.  Using the bound controls in this tiny sample app works fine, of course.  

It obviously saving a tremendous amount of coding, and Freeze seems to be adequately validating all the input through a mixture of triggers and validation events.  Just wondered if we have any believers in bound controls out there, and who might want to venture forth with their own ideas regarding this issue.

It's by no means a hard question, but I've got the points to spare.  So why not?  200 points to the most thoughtful answer.



ASKER CERTIFIED SOLUTION
Avatar of wsh2
wsh2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DreamingEagle
DreamingEagle

ASKER

A most interesting post wsh2, from someone with also a few scars on his back...

Well, let's give it 3 days.  

I have a feeling this post is going to generate a lot of interest.

Maybe Freeze also uses unbound controls and simply took a shortcut in the book, and your idea that it being slow to come down the pipe and go back up it makes a lot of sense.  

I'm being forced to use the Data Environment because of a personal prevalance of the person who approves my timesheets---who is a pretty good coder himself---but in the past I have found boolean functions, once written, to open record sets the old fashioned way, takes less code when developing than using the DE.  Although I am sure you can write boolean functions to open things using the DE, why bother?  It's just a layer of (well, something) standing between me the DB.  Just as soon write something myself that assures me with a true/false whether or not I really have what I think I have, or just sound the alert and back out of what anyone is trying to do.  I'll get the call and fix it.

Ok, I hear you.  One read from the source, however distant, and one write back is better than putting all that buried stuff in motion with bound controls.

The floor is open...:)
Just listening...
Oh.. one other thing.. while I can not document this or remember my source.. I have heard whispers that the Data Environment designer may no longer be supported with the release of VB7. You may want to keep an eye out for this in your journeys.
I commend you for asking this question, I've always been adamant about using unbound controls, and have often wondered if the "problems" with bound controls have been addressed.

Under DAO and ODBC, the reason I never used bound controls is that each control opened up a new ODBC connection to the database, and, unless you put in some code to circumvent it, the bound control would connect to the database and run it's query when the form was loading, which often made forms too slow to appear.

Under ADO, I suspect that you can allow multiple controls to use the same connection, so, you may not have the same problem with managing database resources as you had under DAO and ODBC (but you might, you'd have to monitor what was happening to ODBC at the database level to see for sure).

Managing database resources has always been one of my highest priorities, and so with unbound logic I can read the data into my program and then close the recordsets, thereby minimizing the number of open threads to the database.

Another problem I always had with bound controls is that they immediately updated the database unless you added a lot of code to prevent this.  I figured that if I was going to have to add a lot of code anyway, I might was well get the added flexability of unbound data access.

Maybe someone else can shed some light on the impact of network traffic using the two modes.  I'd suspect that as you scroll up and down through a bound grid, the data controls might be fetching buffers of data, and might generate more network traffic.  But that might also depend on the type of recordset the data control is opened as.

I use unbound controls - it is a lot of code, but I use code generator, so it's not a big problem, once you create your 'templates' and invest time to find the 'best way'.

It is OK to use binding to save some coding, but controls should not be bound directly to database - e.g. in business layer class you can create disconnected recordset and bind it to UI elements.
For the most part I use unbound controls.  Control over the process also means control over the debugging.  I think that for any non-trivial database programming the bound controls can cause hard-to-find-and-solve problems.  The time saved in coding is sometimes lost four-fold in debugging.  I like using the datagrid sometimes, if the task is simple and I need it quick.
mainly just listening - but here is some slight input:

we used bound controls for a college project - and by the time we were done we had to have 9 ADODC controls on one form - talk about slow.  This semester's project will be removing those controls and writing the connections in code
Hello?.. <smile>
Avatar of Guy Hengel [angelIII / a3]
huhu, any neys here?

Actually, i HATE bound controls, as this takes the control from my code for some important actions, especially some complex data checks (not the simple string length checks)...

Cheers
The eagle must be dreaming...

maybe this wakes him up?!
wsh2 deserve the points.
Something in the Experts-Exchange software really has this question messed folks.  For one one thing, when I log-in I do not see the question under my questions in this section.  Please note there is an _ in my handle, but on this page the _ is missing where my handle appears.  I believe---long, long ago---I set up an account as DreamingEagle (without the underbar) but I am not able to log in under that handle now.  I'll try to get the password and see if I can't get this straigtened out.  Under this log-in I can do absolutely nothing.  

I wasn't aware this question was even still out here until I got an email today, which is how I found my way back to the page.
Ok, turns out I do have two accounts.  Sorry for the delay.
Sorry it took so long to get back you.
Ask the Community support to delete one of them if you don't like trouble!!! You can't have 2 accounts here.
DreamingEagle,

Sorry, but emoreau is right. Please tell us which account you don't need anymore.

modder
Community Support
Please keep this account.  It is the one I originally set up and has more points.  
Force accepted by moderator.  In the event Asker returns with additional needs related to this question, please respond and continue the collaboration process.
Thank you,
Moondancer
Community Support Moderator @ Experts Exchange
DreamingEagle,

I have suspended the Dreaming_Eagle account so now you only have the DreamingEagle one.

However, please read the following, and respond to me to tell me you have read it and understood it.

Experts-Exchange is not a news group, in which you can post a question, get the answer, and walk away, or ignore any posts that do not serve to solve your problem.

You can read more about how the site works in our member agreement: https://www.experts-exchange.com/jsp/infoMemberAgreement.jsp

Although the agreement tells you something about how the site works, it doesn't tell you much about the netiquette that has evolved on our site. In Experts-Exchange it is expected that you always provide feeback to those who participate in the questions that you post. And I'll explain why this is the case.

When a question is resolved, it becomes a Previously Answered Question, and will be stored in the database. Users who have similar problems can buy your question for 1/10 of the original point value in order to find a solution to *their* problem.

A a result it is important that you provide feedback to our experts. If their suggestions do not work, tell them why. If they do, award them by grading the answer so that the question does indeed become such a "PAQ".

That way future visitors of this question get the most out of it.

I would also like you to consider this: Our experts are willing to spend some of their precious time to help you solve your problem. A lot of our experts are professionals, to whom time is money. And they're willingly giving up some of their time to help you.

And the only thing we're asking in return is a bit of feedback and an effort on your behalf to participate according to our member agreement and our peculiar brand of netiquette. I think that is a pretty good deal, don't you?



Moondancer had to revisit this question in order to bring it to a close on your behalf. We do not appreciate having to chase after members like this. If this happens again I will suspend your DreamingEagle account.

modder
Community Support Admin
Modder, I can say I am sorry so many times for this...

I do respond to comments posted to my questions.  This is a very unusual exception.

If you need to hear it again, I apologize.