Home All Groups Group Topic Archive Search About

Multiple DB Selects require multiple connections?

Author
1 Oct 2006 4:13 PM
Anil Gupte
This .Net Database stuff is way too complicated.  Just to make a Select
statement on an Access database, I have to first get a connection string,
then open a connection to the database, then create an OLEDBConnection, then
an OLEDBDataAdapter, then a Dataset and then actually use the data. I
counted 12 statements before I can actually populate a Label with some data!
Or am I missing something?

OK, so the real question is, if I need to make a second Select satement, do
I need to go through this whole process all over again starting from opening
a DB connection?  What about Update commands?  Can I do a Select and an
Update on the same dataset?

Thanx for your input.

Author
1 Oct 2006 5:55 PM
Spam Catcher
"Anil Gupte" <anil-l***@icinema.com> wrote in
news:#eRySSX5GHA.1200@TK2MSFTNGP02.phx.gbl:

> This .Net Database stuff is way too complicated. 

No not really - only because you're not used to it yet.


Just to make a
> Select statement on an Access database, I have to first get a
> connection string, then open a connection to the database, then create
> an OLEDBConnection, then an OLEDBDataAdapter, then a Dataset and then
> actually use the data. I counted 12 statements before I can actually
> populate a Label with some data! Or am I missing something?

Yes, it's quite a few lines, but you can wrap everything in a data layer.


> OK, so the real question is, if I need to make a second Select
> satement, do I need to go through this whole process all over again
> starting from opening a DB connection?  What about Update commands?
> Can I do a Select and an Update on the same dataset?

Yes, you can reuse the connection. Depending on the database, a single
connection may serialize the commands (i.e. multiple commands may not run
at the same time), but if this is not a problem for you (as most commands
only take a couple seconds to return), a single connection is A-OK.

BTW, take a look at LLBLGen and similar O/R mappers (.NET teirs, etc), they
map the database into a set of objects and make working with database much
nicer : )