Common connection strings (vs in Connect to SQL Server) for easy viewing at any time

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.