Multiple DB Selects require multiple connections?

A

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.
 
G

Guest

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 : )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top