Connection string in VB.NET

  • Thread starter Thread starter VK
  • Start date Start date
V

VK

Dear All:

We are in the processing of building a new web site using VB.NET and
SQL2000

I had a question about WHERE to store the connection string for SQL dB -
in an include file or web.config file? What are the pros and cons if
any? We may be connecting to more than one database.

Many thanks.
 
VX,

I store mine in the web.config file (intranet only). Actually I store the
ServerName and DatabaseName in the web.config file. I then pass this
information to another component that builds the connection string
dynamically and then connects and returns the connection object. In limited
circumstances where the connection string might include a username and
password, I store the entire connection string in the web.config file and
pass that directly into the connection component.

Storing connection information in the web.config is really only as secure as
your web server so use accordingly.
 
Hi VK,

In addition to Mike's post:
I used to encrypt the connection string (which would have the username and
pwd) and store it in a seperate file, which we decrypt @ run-time. Addition
of new connection strings won't call for a big coding effort.

HTH,
Rakesh Rajan
 
Hi Rakesh,

Looks like you stored the connection string in a file which you would
include on all .aspx pages - which was encrypted.

like Mike suggested he used the connection string from web.config file
for his "intranet" site. Our web site would be the internet.

Thanks.
Vani
 
Back
Top