NEWBIE- connection objects

  • Thread starter Thread starter Lawrence J. Rizzo
  • Start date Start date
L

Lawrence J. Rizzo

Hello,

A couple easy questions...any help is greatly appreciated!

1) I am writing an application that will have a login form. I have defined
the connection and get it all to validate against a USER table in my
database. I then load an MDI form. My question is do I need new connection
objects for each form that will be doing database updates? It just seems to
me that a global connection object would be nice but that would seem to go
against the disconnected ideas of ADO. (Rambling...sorry!)

2) For the connection string, I have it hard coded to work just fine. When
I deply my application, what is the best way to specify the location of the
database? (In my application, this will be an Access database, so, the
path.) In a SUB MAIN() ? Any other ideas?

Thanks, again!

Larry
 
Lawrence,
1) I am writing an application that will have a login form. I have
defined the connection and get it all to validate against a USER table in
my database. I then load an MDI form. My question is do I need new
connection objects for each form that will be doing database updates? It
just seems to me that a global connection object would be nice but that
would seem to go against the disconnected ideas of ADO.
(Rambling...sorry!)

A global connection is strongly disadviced for database servers, for
database files (ms-access) it can have an advantage to use one connection
and keep it open all the time.

For database servers it is the best to create your connection every time new
and dispose it at the end (In VB2005 this behaviour will probably change),
this is because of the connection pooling.
2) For the connection string, I have it hard coded to work just fine.
When I deply my application, what is the best way to specify the location
of the database? (In my application, this will be an Access database, so,
the path.) In a SUB MAIN() ? Any other ideas?

You can set the connectionstring to the connection at any time just before
you open it.

I hope this helps,

Cor
 
Just a suggestion but I would create a database class (mydatabase) and do all
connecting, reading, and writing via this class thru properties and/or
methods of that class. That encapsulates all access to the database in one
class.
 

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

Back
Top