Standard connection for SQL Server authentication:
Data Source = myServerAddress; Initial Catalog = myDataBase; User Id = myUsername; Password = myPassword;
Server =. sqlexpress; database = testDB; uid = sa; pwd = 123456
If you want to use a remote Server to run SQL Server (localhost), you should assign the correct Server to the Data Source attribute in the sample object. In addition, you must specify either of the two supported authentication methods (Windows Authentication and SQL Server authentication. Windows Authentication uses Windows login user identity to connect to the database tutorial, and SQL authentication requires explicitly specifying the SQL Server user ID and password. To use Windows Authentication, you must include the Integrated Security attribute in the connection string:
Data Source = ServerName; Integrated Security = True;
By default, the Integrated Security attribute is False, which means Windows Authentication is disabled. If the value of this attribute is not explicitly set to True, the connection uses SQL Server Authentication. Therefore, the SQL Server user ID and password must be provided. The Integrated Security attribute can recognize other values only SSPI (Security Support Provider Interface, Security Support Provider Interface ). All Windows NT operating systems, including Windows NT 4.0, 2000, and XP, support SSPI. It is the only interface that can be used for Windows Authentication. It is equivalent to setting the value of Integrated Security to True.
When using the connection method of SQL Server, take the local Server (LocalHost) and database (testDB) as an example, you can use the following connection methods:
Data Source = LocalHost; Initial Catalog = testDB; Integrated Security = SSPI; Persist Security Info = False; Workstation Id = XXX; Packet Size = 4096;
Server = LocalHost; Persist Security Info = False; Integrated Security = SSPI; Database = testDB;
Uid = sa; Pwd = sa; Initial Catalog = Northwind; Data Source = LocalHost; Connect Timeout = 20;
In Windows authentication mode, SQL Server uses the Windows security subsystem to verify the validity of user connections. Even if the user ID and password are explicitly specified, SQL Server does not check the user ID and password in the connection string. Because only Windows NT, 2000, and XP support SSPI, if you are using these operating systems, you can only use Windows integrated security policies to connect to SQL Server. No matter which operating system you use, when using SQL Server Authentication, you must specify the user ID and password in the connection string:
Server = ServerName, Data Source = DB; User ID = ID; Password = pwd