Problems encountered while using connection string
The string is as follows "Data source= ******;initial catalog=******; Persist Security info=true;integrated security=true; User Id=sa; password=******; Connect timeout=10 "
Issue One: Connection prompts Windows user permissions and other errors
This problem should be the local Windows user cannot connect to the remote database server, the related property is "Integrated security=true"
Integrated Security=true Connection Property Description: See http://www.cnblogs.com/zxjyuan/archive/2009/03/11/1408991.html
Integrated Security Authentication method
When False, a user ID and password are specified in the connection.
When True, the current Windows account credentials are used for authentication.
The recognized values are true, false, yes, no, and SSPI that is equivalent to true.
The Microsoft Security Support Provider Interface (SSPI) is a well-defined public API that is used to obtain integrated security services such as authentication, information integrity, information privacy, and security aspects for all distributed application protocols. The Application Protocol designer can take advantage of this interface to obtain different security services without modifying the protocol itself.
The above sentence means that this connection uses this interface, if there is no definition will be wrong!
When you use the security authentication mechanism that comes with Windows, you can open the database without adding UID and password
If you do not have that sentence, you must write the uid=sa;password=00 in the connection string;
Otherwise, you can't open the database.
Issue two: Connect timeout=10 is not valid, it will wait a long time (around 40s)
This problem may occur because the machine is not connected to the database host, and the timeout attribute set is valid when connected
Other Notes
Persist Security info=true See http://blog.csdn.net/yzsind/article/details/1507717
The Persist Security Info property is meant to indicate whether or not to save secure information, in fact, it can be simply understood as "whether ADO saves password information after a successful database connection",
True means save, false means no save
ADO defaults to True
(the default for ADO is False, not tested, according to reference)
So the default false is generally used
SQL Server Connection String learning