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

Forum statistics

Threads
474,262
Messages
2,571,059
Members
48,769
Latest member
Clifft

Latest Threads

Top