My current system includes an Access 2003 mdb front and am mdb back end end
(on a server - about 20 users). I'd like to put the tables on a SQL server
but keep the mdb front end (multi-user of course). The current mdb front
end contains a utility that re-links the mdb tables and it, like everything
else on the mdb front end, is written in DAO - I inherited it and did not
write it myself. CONVERSION OF THIS UTILITY IS MY CONCERN. I know I need
to re-write it at least a little but can I do it in DAO?
Yes, you most certanly can keep *most* of your code in dao. I would not
worry too much
Now, I found an
*ARTICLE* that contains DAO code to create a DSN-less link to SQL Server,
and for some reason I saw this article as manna from heaven, that it's my
solution (to the utility conversion problem). Or is this DSN-less stuff
even relevant to my problem?
Actualy, you are correct, the dsn less stuff is actualy confising the issue
here.
But of course it's a source of confusion
because I thought ADO must be used when the
tables were on a SQL Server! I have been somewhat anxious about
converting
my existing DAO to ADO, and have even started using ADO in some of my new
coding projects.
That is just fine, but once again, you can contiue to use the dao code that
you have.
(yes, ado is better)
So, as a genearl rule:
new projects, and using sql server, then use ado.
old existing project with lots of code, then contiue to use dao
Granted I'll have to re-code this re-linking utility
Yes, and in fact, what you do is cntinue to use your linked tables, but now,
you simply link the tables to sql server via odbc (and, yes, you will and
can use dao code).
You new re-linking code to sql sserver can be found here:
http://members.rogers.com/douglas.j.steele/DSNLessLinks.html
So, here is what happens:
you upside your data to sql server, and then change all the linked
tables to not look at the back end, but now they look at sql server.
Here is some thoughts and comments:
** Ask the user what they need before you load a form!
The above is so simple, but so often I see the above concept ignored.
For example, when you walk up to a instant teller machine, does it
download every account number and THEN ASK YOU what you want to do? In
access, it is downright silly to open up form attached to a table WITHOUT
FIRST asking the user what they want! So, if it is a customer invoice, get
the invoice number, and then load up the form with the ONE record (how can
one record be slow!). When done editing the record...the form is closed, and
you are back to the prompt ready to do battle with the next customer. You
can read up on how this "flow" of a good user interface works here (and this
applies to both JET, or sql server applications):
http://www.attcanada.net/~kallal.msn/Search/index.html
My only point here is restrict the form to only the ONE record the user
needs. Of course, sub-forms, and details records don't apply to this rule,
but I am always dismayed how often a developer builds a nice form, attaches
it to a large table, and then opens it..and the throws this form attached to
some huge table..and then tells the users to go have at and have fun. Don't
we have any kind of concern for those poor users? Often, the user will not
even know how to search for something ! (so, prompt, and asking the user
also makes a HUGE leap forward in usability. And, the big bonus is reduced
network traffic too!...Gosh...better and faster, and less network
traffic....what more do we want!).
** Don't use quires that require more then one linked table
When you use
ODBC, one table could be on the corporate server, and the other ODBC might
be a FoxPro table link 3 computers from the left of you. As a result..JET
has a real difficult time joining these tables together..and JET can not
assume that the two tables are on the same box..and thus have the "box" join
the tables. Thus,while jet does it best..these types of joins can often be
real slow. The simple solution in these cases is to change the query to
view..and link to that. This is the least amount of work, and means the
joins occur on the server side. This also applies to combo boxes. Most
combos boxes has sql embedded in them. That sql has to be processed, and
then thrown to a linked odbc table. This is a bit sluggish. (a form can have
maybe one, or two combos..but after that ..it will start to load slow). So,
remove the sql from the combo box, build a view..and link the combo box
direct to that view (JUST USE the view name...the sort, and any sql need to
be in the view). The result is quite good combo box load performance. (and
again, not very much work. There are other approaches that can even speed
this up more..but we have to balanced the benefits VS. the amount of work
and coding. I don't think once should re-code all combo boxes to a call back
with a pass-through reocrdset..but that can be a solution also).
So, again, you can freely link all your tables to sql server via odbc, and
ONLY work on things that don't perform well
Of course, if you are using a ADP access project, the above points
about the joins with more then one table does NOT apply..since all
queries execute on the sql server side.
** Of course, if you do have sql with more then one table..then pass-though
is the best if using odbc.
** You can continue to use bound forms..but as mentioned..restrict the form
to the one record you need. You can safely open up to a single invoice,a and
even continue to use the "where" clause of the openform. Bound forms are way
less work then un-bound forms...and performance is generally just is good
anyway when done right.
** Large loading of combo boxes. A combo box is good for about 100
entries. After that..you are torturing the user (what..they got to look
through 100's of entries!). So, keep things like combo boxes down
to a min size. This is both faster..and MORE importantly it is
kinder to your users.
After all, at the end of the day..what we really want is to make
things easy for the users...and treat them well.. It seems that
treating the users well, and reducing the bandwidth
(amount of data) goes hand in hand. So, better applications
treat the users well..and run faster!
Hence, you simply link all your tables to sql server, and THEN
fix the parts that don't work well.
A few more tips:
make sure that you add a timestamp field to the sql server tables, and this
stamp is exposed to ms-access
(ms-access with linked odbc tables (your dao) uses the timestamp to help
figure what the heck needs to
be updated.
So, for a existing applications, you can keep you dao, and get good
performance. In fact, you only have to change
code and things that don't work.
For example, in dao to a ms-access table, you can get the current autonumber
id as follows:
:
dim rstRec as DAO.RecordSet
dim lngNewID as long
set rstRec = currentdb.OpenRecordSet("yourtable")
rstRec.AddNew
rstRec!City = "Edmonton"
lngNewID = rstRec!ID
rstRec.Update
rstRec.Close
set RstRec = Nothing
At this point, lngNewID is set to the last id created.
When using sql server, you have to force the update, so, all my code (which
works both for JET, and sql server) is now:
rstRec.AddNew
rstRec!City = "Edmonton"
rstRec.Update
rstRec.BookMark = rstRec.LastUpdated
lngNewID = rstRec!ID
So, *most* of your dao code will work, but as above, some things do need to
be changed.
--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn
Post a follow-up to this message