SQL connection string description

Source: Internet
Author: User
Tags dsn odbc connection

SQL connection string description

From: http://hi.baidu.com/arslong/blog/item/b23307e76252342cb8382001.html

Item1

Commonly used declarations in connection strings include:
Server Declaration: data source, server, and ADDR.
Database Declaration: initial catalog and database.
Integrated Security Statement for Windows accounts: integrated security and trusted_connection.
Use the Security Statement of the database account: user ID and password.

1) for the account accessing the database, we usually see the string connection of ADO. Net in some references as follows:
String connstr = "Server = localhost; user id = sa; Password = xxx; database = northwind ";

2) For accounts integrated with Windows security, the connection string is generally written as follows:
String connstr = "Server = localhost; Integrated Security = sspi; database = northwind ";
Or string connstr = "Server = localhost; trusted_connection = yes; database = northwind ";

Using Windows integrated security verification has many advantages in accessing the database: higher security, faster access, less security architecture re-design, hard-coded connection strings, etc, it is worth using.

Item2 set the connection string Option

The connection string contains the web application.ProgramAll information required to connect to the database. Dreamweaver inserts this string in the server script on the page so that the application server can process it later.

For Microsoft Access and SQL Server databases, the connection string contains the following parameters separated by semicolons:

ProviderSpecifies the ole db provider of the database. For example, the following are parameters of common ole db providers of access, SQL Server, and Oracle databases:

 
Provider = Microsoft. Jet. oledb.4.0;... provider = sqloledb;... provider = oraoledb ;...

For the parameter values of your ole db provider, see the documentation provided by the provider or consult your system administrator.

If the "provider" parameter is not included, the default ole db provider of ODBC is used, and you must specify the appropriate ODBC driver for the database.

DriverSpecifies the ODBC driver used when no ole db Provider is specified for the database.

ServerSpecify the server that hosts the SQL Server database (If your web application runs on another server ).

DatabaseIs the name of the SQL Server database.

DBQIs the path to a file-based database (such as a database created in Microsoft Access. This path is the path on the server that hosts the database file.

UIDSpecify the user name.

PWDPassword.

DSNIs the data source name (if used ). You can omit other parameters of the connection string based on the way you define the DSN on the server. For example, if other parameters are defined when you create a DSN (see use DSN ),DSN = resultsIt can be a valid connection string.

For other types of databases, connection strings may not use the parameters listed above, or they may have different names or uses. For more information, see the documentation provided by the database supplier or consult your system administrator.

The following is an example of a connection string that creates an ODBC connection to the ACCESS database named trees. mdb:

 
Driver = {Microsoft Access Driver (*. mdb)}; DBQ = c: \ Inetpub \ wwwroot \ research \ trees. MDB

The following is an example of a connection string. It creates a connection to the ole db of the SQL Server database named Mothra ON THE Gojira Server:

 
Provider = sqloledb; server = Gojira; database = Mothra; uid = jsmith; Pwd = orlando8

 

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.