How to get connection string

Discussion in 'ASP .Net' started by SF, Jun 20, 2008.

  1. SF

    SF Guest

    Hi

    How to get connection string from web.config?

    SF
     
    SF, Jun 20, 2008
    #1
    1. Advertising

  2. //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!
    |
    *************************************************
    "SF" <> wrote in message
    news:...
    > Hi
    >
    > How to get connection string from web.config?
    >
    > SF
    >
     
    Cowboy \(Gregory A. Beamer\), Jun 20, 2008
    #2
    1. Advertising

  3. SF

    Cyril Gupta Guest

    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
     
    Cyril Gupta, Jun 20, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gregory_may
    Replies:
    1
    Views:
    605
    Bruce Barker
    Nov 21, 2005
  2. Replies:
    1
    Views:
    10,185
    Karl Seguin [MVP]
    Feb 22, 2006
  3. Linus Nikander
    Replies:
    5
    Views:
    549
  4. Replies:
    3
    Views:
    850
    Samuel R. Neff
    Aug 3, 2007
  5. Wei  Lu
    Replies:
    2
    Views:
    5,893
    Wei Lu
    Feb 16, 2009
Loading...

Share This Page