There are two types of SQL Server authentication, one is Windows authentication, and the other is SQL Server authentication
Windows Authentication Connection string:
string connectionString = "data source=localhost;database= database name; Integrated security=true ; User Instance=false; ";
Integrated security refers to the integration of security, is true, is the use of integrated security, the latter refers to the user Instance instance, here is false, do not use the user instance, so as to facilitate the use of different users, which is my more commonly used connection string. For more details on user Instance refer to the link below, very detailed
Http://zhidao.baidu.com/link?url=c7dA0eVo7gby23pocNSLFoWSJHGElFNJltC9VZ2uKC6Ma42KNl1k8vsl4PABGihHb56_ 62kuloyehizcgss-gx3jmawrm19qzdphmnvehby
SQL Server Authentication Connection string:
string @" server= server name; database= database name; uid= user name; pwd= password ";
Of course, I wrote this a little bit easier.
For more detailed reference:
Http://www.cnblogs.com/tough/archive/2011/11/18/2254076.html
These connection strings are generally written in the configuration file.
Right item Add New item Find application configuration file click Add
Add the following code in app. Config
<appSettings> <add key="connectionString" value=" the string you want to connect "/> </appSettings>
Then you can use it in your project.
string constr = System.Configuration.ConfigurationManager.AppSettings.Get ("connectionString ");
Common connection strings (vs in Connect to SQL Server) for easy viewing at any time