Well most of the aspects of this had already been covered in the other samples,
but day after day the requests kept rolling in for a simple form to DB script!
As such I finally just decided to write one but I would like to say that I'd
appreciate it if you'd take a look at how these samples work and try to make
some changes to get them to work the way you want. A lot of people are actually
emailing me asking me to change the code or write code specifically for
them! While I'd love to help I just don't have the time!
It's a pretty simple set of code, but I've added some things just to expose you
to them. Specifically I do some error handling using the built in Err object
and actually even raise my own error at one point. I also have used OLE DB
instead of ODBC. I've switched to OLE DB for most of my DB work lately (it
seems to be faster and more stable) so I figured I'd share that with our
visitors.
Finally (and probably most importantly) I'm not using a recordset for this and
have taken a few steps to make the DB work faster. I simply build a SQL command
and do a connection execute. You'd think that would be enough, but even if your
command returns no records this still returns a recordset! To stop it I specify
adExecuteNoRecords to tell it that I know that no recordset will be returned
and that one shouldn't be created! Heck that tip alone is worth the time you'll
spend reading the code! And don't let the length scare you... most of it's
just comments!
Oh and I almost forgot... this inserts into our sample DB which you can view
from the Simple DB Sample. If you want an Access
version you can download one here.