In the msdn Chinese version, there are many translations that are not translated, or there is a problem with translation. I will refer to the English version MSDN and the Chinese version of MSDN, with my own experience, put the database connection string, as follows:
English version can be read the following address:
Http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemDataSqlClientSqlConnectionClassConnectionstringtopic.asp
SqlConnection.connectionstring properties
Connectionstring is similar to the OLE DB connection string, but is not the same. Unlike OLE DB or ADO, if the "Persist Security Info" value is set to false (default), the returned connection string is the same as the user settings, but removes security information. Unless "Persist Security Info" is set to True, the SQL Server .NET Framework data provider will not remain, nor will the password in the connection string.
You can connect to the database using the connectionstring property. The following example illustrates a typical connection string.
"Persist security info = false; integrated security = sspi; database = northwind; server = mysqlserver"
The Connectionstring property can only be set when the connection is closed. Many connection string values have corresponding read-only properties. When setting the connection string, all of these properties will be updated (unless an error is detected). No properties are updated when an error is detected. The SqlConnection property returns only those settings included in Connectionstring.
To connect to a local machine, specify the server as "(local)." (You must always specify a server.)
Reset Connectionstring on the closed connection resets all connection string values (and related properties) including the password. For example, if you set a connection string, it contains "Database = Northwind", then reset the connection string to "Data Source = MyServer; Integrated Security = SSPI", the Database property will no longer be set to Northwind.
The connection string is analyzed immediately after setting. If there is an error in the syntax at the time of analysis, the run library exception is generated, such as ArgumentException. Other errors are only found when trying to open the connection.
The basic format of the connection string includes a series of keyword / value pairs separated by a semicolon. The equal sign (=) connects each keyword and its value. To include a value containing a semicolon, single quotes, or a double-quotes, the value must be enclosed in a double quotem. If the value contains the semicolon and dual quotation characters, the value can be enclosed in single quotes. If this value begins with a dual quotation number, single quotes can also be used. Conversely, if the value starts in single quotes, double quotes can be used. If the value contains single quotes and dual quotes characters, it must be paired when the quotation marks enclosed in the value each appears.
To include the leading or trailing space in the string value, the value must be enclosed in a single quotation number or a double number. Even if an integer, Boolean or enumerated value is enclosed, any preamble or trailing space around it will be ignored. However, retain a string keyword or a space within the value. When using the .NET Framework version 1.1, you can use single quotes or double quotes in the connection string without using separator (for example, Data Source = My'Server or Data Source = My "Server), but quotation marks cannot be valued. The first or last character. To include the equal sign (=) in the keyword or value, it must be another equal sign before it. For example, in the hypothetical connection string,
"Key == word = value"
The keyword is "Key = Word" and the value is "value".
If a particular keyword in the "keyword = value" pair appears multiple times in the connection string, the last one listed is used for value set.
Keywords are not case sensitive.
The following table lists the valid names of keyword values in Connectionstring.
Name Default Value Description Application Name Application Name, if the application name is not provided, the default is: ". Net SqlClient Data Provider" AttachDbFileName- or -Extended Properties- or -Initial File Name can connect to the name of the primary file of the database, including Complete path name. You must use the keyword "database" to specify the name of the database. Connect Timeout - or -Connection Timeout15 Wait for time length (in seconds) that is waiting to be connected to the server before terminating the attempt and generates an error. Current Language SQL Server Language Data Source - or -Server- or name or network address of the SQL Server instance to connect to or -Addr- or -network address. Encrypt'False 'When this value is TRUE, if the server is installed, SQL Server uses SSL encryption to all data transmitted between the client and the server. The identifiable value is true, false, yes, and no. The name of the Initial Catalog- or the -database database. Integrated Security - or -Trusted_Connection'false 'When you are false, you will specify the user ID and password in the connection. When you are TRUE, you will use the current Windows account credentials to authenticate. The recognizable value is True, False, Yes, NO, and SSPI equivalent to TRUE (strongly recommended). Network library - or -net'dbmssocn 'is used to establish a network library that is connected to the SQL Server instance. Supported values include DBNMPNTW, DBMSRPCN (Multi-Protocol), DBMSADSN (Apple Talk), DBMSGNET (VIA), DBMSLPCN (Shared Memory), and DBMSSPXN (IPX / SPX) and DBMSSOCN (TCP / IP). The corresponding network DLL must be installed on the system to connect. If you do not specify a network, use a local server (such as ","), use shared memory. Packet size8192 The size of the network packet used to communicate with the instance of SQL Server, in bytes. Password - or the password logged in to the -pwd SQL Server account (not recommended. In order to maintain the highest level of security, it is highly recommended to use Integrated Security or Trusted_Connection Keywords). Persist security info'false 'When this value is set to false or NO (strongly recommended), if the connection is open or is in an open state, the security sensitive information (such as a password) will not return as part of the connection. Resetting the connection string will reset all connection string values including the password. The identifiable value is true, false, yes, and no. User ID SQL Server login account (recommended not to use. In order to maintain the highest level of security, it is highly recommended to use Integrated Security or Trusted_Connection Keywords). The name of the WorkStation ID Local Computer Name is connected to the workstation of SQL Server.
The following table lists the valid names of the connection pool value in Connectionstring. For more information on connecting pools, see the SQL Server .NET Framework data provider connection pool. Name Default Description Connection Lifetime0 When the connection is returned to the pool, the creation time is compared to the current time. If the length of time (in seconds) exceeds the value specified by the Connection Lifetime, the connection will be destroyed. This is useful in the aggregation configuration (for enforcing the running balance between the server in the run and the server just in the online status). Zero (0) value will make the pool connection have the largest connection timeout. Connection Reset'true 'Determines whether the database connection is reset when the database connection is extracted from the pool. For Microsoft SQL Server version 7.0, set to false to avoid access to an additional server round trip, but notice that the connection status is not reset this (such as database context). Enlist'true 'When this value is TRUE, the pool program is automatically registered in the current transaction context of the thread. The identifiable value is true, false, yes, and no. The maximum number of connections allowed in the Max Pool Size100 pool. The minimum number of connections allowed in the MIN POOL Size0 pool. POOLing'true 'When this value is TRUE, the system will extract the SQLConnection object from the corresponding pool, or create the object when necessary and add it to the corresponding pool. The identifiable value is true, false, yes, and no.
When setting the keywords that require the Boolean value or connect the pool value, you can use 'yes' instead', 'NO' instead 'false'. The integer value is expressed as a string.
Note that the SQL Server .NET Framework data provider uses its own protocol to communicate with SQL Server. Therefore, when connected to SQL Server, it does not support the use of an ODBC Data Source Name (DSN) because it does not add an ODBC layer. WARNING In this release, it should be quite careful when constructed connection strings in the application (for example, when retrieving user IDs and password information from the dialog), it should be quite carefully. Applications should ensure that users cannot embed additional connection string parameters in these values (eg, enter "ValidPassword; Database = Somedb" as passwords to try to connect to other databases).
Example
[Visual Basic, C #] The following example creates a SQLConnection and sets some properties.
[Visual Basic]
Public Sub CreateSqlConnection ()
DIM MyConnection As New SqlConnection ()
MyConnection.connectionstring = "Persist security info = false; integrated security = SSPI; database = northwind; server = mysqlserver; connection timeout = 30"
MyConnection.Open ()
End Sub 'CreateSqlConnection
[C #]
Public void createSqlConnection ()
{
SqlConnection myconnection = new sqlConnection ();
MyConnection.connectionstring = "Persist security info = false; integrated security = SSPI; database = northwind; server = mysqlserver; connection timeout = 30; myconnection.open ();
}
Monday, March 08, 2004 10:28 PM
Feedback
#
Reply: SQLCONNECTION.CONNECTIONSTRING attribute in MSDN
5/5/2004 3:51 PM
Kenway
May I ask what is the reason:
My code is as follows:
Void Page_Load (Object R, Eventargs S)
{
SqlConnection myconnection = new sqlConnection ();
MyConnection.connectionstring = "Persist security info = false; integrated security = SSPI; Database = TEST; Server = SilverBase; connect timeout = 30";
MyConnection.open ();
Sqldataadapter myadapter = new sqldataadapter ("Select * from s", myconnection);
DataSet DS = New DataSet ();
Myadapter.fill (DS, "SS");
New.datasource = DS.TABLES ["ss"]. DefaultView;
New.DATABIND ();
}
Why do you compile errors: User 'NT Authority / Network Service' Login Failure
#
Re: Squinate the sqlconnection.connectionstring attribute in MSDN
8/19/2004 10:30 am
HPY223
Hello, I ask a question that has nothing to do with the above, I want to send SMS to my mobile phone through the website, how to implement it, I use C #, trouble you, give back! Thank you