Don't need connection.open() for adapter.Fill.. right!?

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

I repeatedly see questions in the example exams
from the Microsoft press self paced training kits
that assert that a connection needs to be opened
before adapter.Fill() can be called, and my
understanding is that this is absolutely not the
case.

Has anyone else noticed this?
 
It opens itself. It's a good argument that opening it manually and trapping
open exceptions is prudent, but you don't need to. And take for example an
implementation I've seen. The connection is opened and a timer starts with
500 ms intervals. It keeps going with DoEvents at the bottom of the loop
until it opens. This is one of several server unfriendly methods I've seen
of handling opening and closing the connection. You can do it manually, but
if you do, do it like the book examples. Freestyling in this regard can be
ghastly. (I've even seen an implementation that spawns new threads and can
kill even the most robust server)

You are right though about the discrepancy. I think it's done for clarity.

Cheers,

Bill
 
Back
Top