Deleting Password From ConnectionString

Saran Jawaban Deleting Password From ConnectionString

  • 09 April 2009 14:13
     
     
    I set up my sql connection just like below:
     SqlConnection myconn = new SqlConnection();
     myconn.ConnectionString = "Data Source=192.168.0.70;Initial Catalog=KOGS;User ID=nrrr;Password=86547;"

    Meanwhile this connection object is static and in a static class. Anyway, when i want to use or open the connection, i notice that it has deleted the password from the connection string so it cannot connect to database. Why does it delete the password from the connection string? It ,the connection string, becomes as below after it delete:
    "Data Source=192.168.0.70;Initial Catalog=KOGS;User ID=nrrr;"

Semua Balasan

  • 09 April 2009 14:39
    Moderator
     
     
    That's bizarre.  Is that really your code? Have you put a break point right after the line setting the connection string?  I've never seen a password simply disappear like that.
    David Morton - http://blog.davemorton.net/
  • 09 April 2009 14:55
     
     
    Weird indeed...

    i've never personally used "User ID" as syntax for the user, I use "user=asdf;password=asdf" in my connection strings.
  • 09 April 2009 14:57
     
     
    Completely agreed with David . Even I have never seen password disappearing. There might be some issue. Check the connection string that you are getting using a breakpoint.

    Sandeep Aparajit | http://sandeep-aparajit.blogspot.com | Mark useful posts as Answer/Helpful.
  • 09 April 2009 15:04
     
     
    Yes I have just put a breakpoint after setting up the connection string then i follow the lines. After line goes to another void then i cant see the password, i simply disspears.
  • 09 April 2009 15:07
    Moderator
     
     

    At which point does it disappear?  Which line?  What is the line immediately above that one? 

    Please post code. 

    Sandeep, 

    Please edit your previous post, it seems you copied a bit too much, and this thread is a little unsightly now.  :)  Try using the sandbox forums to get used to the format.


    David Morton - http://blog.davemorton.net/
  • 09 April 2009 18:03
     
     
    This is my hunch: Sql Server is set up for Windows authentication, not mixed one, thus the system makes a correciont?
    AlexB
  • 13 April 2012 16:42
     
     Saran Jawaban

    Use PersistSecurityInfo switch :

    myconn.ConnectionString = "Data Source=192.168.0.70;Initial Catalog=KOGS;User ID=nrrr;Password=86547;PersistSecurityInfo=true"

  • 13 April 2012 16:57
    Moderator
     
     

    FYI the connection string class is set up to not show you the password when getting the connection property.  This is by design for security reasons.  The password would still be there but you just won't see it.

    Michael Taylor - 4/13/2012
    http://msmvps.com/blogs/p3net

  • 14 April 2012 20:49
     
     Saran Jawaban

    Hello CoolDadTx,

    It's not totaly exact... It depends on the provides you use !

    By defaut and after the connection is opened, SqlServer provider erase the password on ConnectionSring property (but pasword still there it's exact) except if you specified PersistSecurityInfo=true, in which case the password is not deleted

    Other provider do may not