open a database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I commented out the statement con.open() by a mistake . Surprisingly,
everything worked normally.

I am wondering, does the data adapter open a database?
da.Fill(ds, "Table");

I could not find any information about it ....

Thanks,

Lubomir
 
Hi Lubomir,

DataAdapter Fill opens the connection if it isn't already opened. If it isn't opened, then it will also close the connection afterwards. If the connection is already opened, then the dataadapter won't close it either.
 
Hi Lubomir, as Morten says thats right -which is why using a dataadapter and
letting it handle the connection is so effecient.
Ironically I only realised the dataadapter didnt require an open connection
myself when I sat my C# Win app Exam and saw code which didnt open it!
What we need is a super-compiler which gives us feedback on the
inefficiencies of our code and how it can be improved -but I guess when that
happens there will be no need for us :-)

Br,

Mark.
 
Back
Top