Clumsy birds have essay: code that connects to SQL Server database (Windows authentication method supplement) in ADO

Source: Internet
Author: User

The previous article only writes the connection code of the database SQL Server connection mode here to add a connection to Windows Authentication mode:

about how vs Connect SQL Server database Windows Authentication works:

The top menu in the 01.VS window selects data in turn

02. Add a new data source

03. Then select the database and click Next

As shown in the following:

04. Select the data set and click Next

As shown in the following:

05. Click New Connection, pop up the dialog box

As shown in the following:

06. The data source is displayed as Microsoft SQL Server SqlClient If you do not need to click Change modification to Microsoft SQL Server SqlClient; server name fill SQL Server Server name in Windows Authentication mode; Log on to the server select Use Windows Authentication; Connect to a database Select the first item, select or fill in the database that you want to connect with.

07. Click the bottom left corner to test the connection, and the popup dialog shows that the test connection was successful. Then click OK to close the dialog box and click OK.

As shown in the following:

08. Here is a connection string click on the front + sign

As shown in the following:

09. Tap the plus sign to expand, copy the resulting string after the point is canceled, and then paste the location of the database connection string in the previous C # code

Comparison of connection strings in two ways:

SQL Server Authentication: string constring= "server=.database=teaching;uid=sa;pwd=123456";

Windows Authentication: String constr= "Data source=.;i Nitial catalog=teaching;integrated security=true ";

Clumsy birds have essay: code that connects to SQL Server database (Windows authentication method supplement) in ADO

Related Article

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.