Briefly describes the pattern of connection strings when Vc_ado connects SQL Server

Source: Internet
Author: User
Tags connect

One, the first connection string to connect to SQL Server:

is for SQL SERVER and Windows for the database authentication mode,

The connection string is:

CString strconn;

strconn = "Provider = sqloledb.1;\

Persist Security Info = true;\

User ID = sa;\

Password=123456;\

Initial Catalog = tempdb;\

Data Source = 127.0.0.1 ";

(contains 6 entries, with user name and password, database name, server name (server name can be on the network, at this time is an IP address))

Second connection string to connect SQL Server:

For the authentication mode is Windows only,

The connection string is:

Strconn= "

Provider = sqloledb.1;\

Integrated security=sspi;\

Persist Security Info =false;\

Initial Catalog = tempdb;\

Data Source = (local) ";

(contains 5 items, because Windows is already authenticated, so no longer requires a username and password, and if it is a native SQL Server, the server name can be written as (local))

Third, the second connection string to connect to SQL Server:

For ODBC-only connection methods,

The connection string is:

Strconn= "

Provider = sqloledb;\

Server = (local); \

Database = tempdb;\

UID = sa;\

pwd=12345; "

Above three kinds of connection way, remember any one can, recommend the use of the second

About the connection string problem, we can use the UDL file to deal with ~ ~

Create a new empty TXT file. Change the extension to UDL.

The UDL itself is a text file.

Its primary role is to view the configured database connection words. Configure it first. Then use Notepad to open

Eg: we create a test.udl file on the desktop,

1. If you are connecting to a SQL Server database, the provider selection:

Microsoft OLE DB Provider for SQL Server,

Related Article

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.