It's funny you should ask, actually, because I find myself going in the
opposite direction.
My beginnings were entirely based in Access, so I started by always using
the built-in properties, tying data directly to forms, etc. For small to
medium applications this worked well. Then I discovered the concept of
class modules to represent tables, collections, etc., and started isolating
some things from the obvious, easy way to do them in Access, in order to
provide more flexibility. Then I discovered ADO, and started programming
using that instead of DAO (though some days I wondered why).
More recently, we've transitioned from Access as a back end to SQL Server as
a back end. Then I discovered why I transitioned to ADO. All of a sudden,
things like asynchronous commands became a little more logical and useful.
I also discovered the pitfalls of the .Index/.Seek combination. What had
been the fastest way in Access was impossible in SQL Server. Even in other
code where I had used more generic ADO like .Open <tablename>,
..Find/.Filter, I discovered the added pitfalls of opening a full table
against a SQL Server back end.
While I still use Access' ability to tie forms/listboxes directly to queries
and such, for my class modules, I'm definitely going to more of a generic
approach that's easier to maintain across different front-/back-ends. For
example, sprinkled liberally throughout my code, you can now find lines
like:
DataProject.MakeQuery("MyTableOrView","MyFieldList <or blank for
*>","MyField = " & DataProject.MakeServerString(MyString), "MyOrderByField
DESC")
MakeQuery then handles the specific syntax of a generic Select query, while
MakeServerString handles things like converting apostrophes, CR/LF combos,
etc., and then wraps the string in appropriate delimiters for the server (in
SQL Server's case, single quotes). Similarly, when I develop the need, I'll
be adding DataProject.MakeDeleteQuery, DataProject.MakeInsertQuery, and
whatever else seems appropriate.
Since our next step is .NET instead of VB6, I'm not sure where I'll end up
eventually...with its ability to assign class properties directly to
controls, like you, I'm beginning to wonder whether I'm doing a lot of this
for nothing.
Rob
So what's your favorite philosophy?
I've always been old-school in that I either developed a class module
or dozens of specific stored procs for Add, Update, Delete to support
all tables (trying to keep SQL from being sprinkled all over my
project). However, ADO and MS Access GUI make it so easy to tie SQL to
objects or do stuff on the fly I find myself starting to get sloppier.
I find it difficult to teach others to "black box" the SQL code because
it looks so tedius.
Heck I didn't even know that you could do what Alex pointed out:
currentproject.connection.execute("Delete from TblTest Where
Test_ID=1")
me.requery
Now I'm really in trouble!
I've spent years developing VB6/Oracle DB interfaces (using Oracle
Objects for Ole instead of ADO) and never had SQL in the User interface
code. But now I find it silly to develop a stored proc to load a list
box.
I guess my question is - do most of you continue to separate the SQL
from the interface or has the power of ADO lured you into blending?
Thanks