ConnectionString loses password after connection.Open

后端 未结 3 1945
醉梦人生
醉梦人生 2020-12-07 16:26

i\'m using ADO.NET to get some information from the database on a server,
so this is what i do:

string conStr = \"Data Source=myServer\\SQLEXPRESS;Initia         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 17:18

    This is by design, for security reasons. From MSDN:

    The ConnectionString is similar to an OLE DB connection string, but is not identical. Unlike OLE DB or ADO, the connection string that is returned is the same as the user-set ConnectionString, minus security information if the Persist Security Info value is set to false (default). The .NET Framework Data Provider for SQL Server does not persist or return the password in a connection string unless you set Persist Security Info to true.

提交回复
热议问题