ADO.NET

xiaoxiao2021-03-06  46

Connect database

[C #]

SqlConnection nwindconn = new SqlConnection ("data source = localhost; integrated security = sspi; initial catalog = northwind");

nwindconn.open ();

Configure web.config files

In the application profile (web.config), you can establish the authentication mode used by the application, and establish an application to simulate user credentials (ie the application will run as this user's identity) mode?

Configure web.config to allow Windows integration security

Open the application's web.config file and add the following elements to it:

Element may already exist.

Note that the elements in Web.config are case sensitive.

Create a connection string

When you create a connection string to access SQL Server, you must include informing the SQL Server you are using the properties of Windows integration security.

Configure connection string for Windows integration security

In any connection string of SQL Server, contain the property trusted_connection = yes and remove the username and password properties.

The following shows a typical connection string for Windows integration security configuration:

"Workstation ID = WebServer1; packet size = 4096;

Trusted_connection = yes; data source = mysqlservers;

Persist security info = false; initial catalog = northwind

转载请注明原文地址:https://www.9cbs.com/read-80829.html

New Post(0)