How to get connection string

C

Cowboy \(Gregory A. Beamer\)

//C#
string connectionString =
ConfigurationManager.ConnectionStrings["connStringName"].ToString();

'VB
Dim connectionString as String = _
ConfigurationManager.ConnectionStrings("connStringName").ToString()
 
C

Cyril Gupta

Connection string ....

Now you know how, so let me tell you something interesting.

If someone gets hold of your connectionstring, they can potentially
access your db (cause your connectionstring has the db user name, and
pwd). Remember never to use a literal connection string, it's best to
put it in web config.

If possible use Windows authentication, and you will be safer, cause
you would not have user id and pwd in the connectionstring, and nobody
would be able to gain access to the db using those.

Cheers!
Cyril Gupta
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top