How to get connection string

  • Thread starter Thread starter SF
  • Start date Start date
//C#
string connectionString =
ConfigurationManager.ConnectionStrings["connStringName"].ToString();

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

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
 
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

Back
Top