Database connection string Daquan SQL Server

Source: Internet
Author: User
Tags odbc connection
Database connection strings are frequently used, but there are many database types and there are many connection methods. Below we provide various database connection strings for convenient query.
SQL Server

ODBC connection mode

Standard secure connection
Driver = {SQL Server} ; Server = Myserveraddress ; Database = Mydatabase ; UID = Myusername ; PWD = Mypassword ; Trusted connection
Driver = {SQL Server} ; Server = Myserveraddress ; Database = Mydatabase ; Trusted_connection = Yes ;
Prompt for username and password

You need to set a property equal Adpromptalways Connect the object, and then use the connection string

Oconn. properties ("prompt") = adpromptalwaysDriver={SQL Server};Server=Myserveraddress;Database=Mydatabase;

Ole db, oledbconnection connection method (. NET)

Standard secure connection
Provider = Sqloledb ; Data Source = Myserveraddress ; Initial catalog = Mydatabase ; User ID =Myusername ; Password = Mypassword ;
Trusted connection
Provider = Sqloledb ; Data Source = Myserveraddress ; Initial catalog = Mydatabase ; Integrated Security = Sspi ;
Connection to the specified server
Provider =Sqloledb ; Data Source = Myservername \ theinstancename ; Initial catalog = Mydatabase ; Integrated Security = Sspi ;
Prompt for username and password
Oconn. provider = "sqloledb" oconn. properties ("prompt") = adpromptalways Data Source = Myserveraddress ; Initial catalog = Mydatabase ;
Connect by IP Address

Here Data Source = 190.190.200.100, before 1433 190.190.200.100 is an IP address, and 1433 is a port.

Provider = Sqloledb ; Data Source = 190.190.200.100, 1433 ; Network Library = Dbmssocn ; Initial catalog = Mydatabase ; User ID = Myusername ; Password = Mypassword ;

Sqlconnection connection method (. NET)

Standard secure connection
Data Source = Myserveraddress ; Initial catalog = Mydatabase ; User ID = Myusername ; Password = Mypassword ;
Standard Security another method of connection writing
Server =Myserveraddress ; Database = Mydatabase ; User ID = Myusername ; Password = Mypassword ; Trusted_connection = False ;
Trusted connection
Data Source = Myserveraddress ; Initial catalog = Mydatabase ;Integrated Security = Sspi ;
Trusted connection Another connection method Server = Myserveraddress ; Database = Mydatabase ; Trusted_connection = True ;
Connection to the specified server Server = Myservername \ theinstancename ; Database =Mydatabase ; Trusted_connection = True ;
Trusted connection to CE Devices
Data Source = Myserveraddress ; Initial catalog = Mydatabase ; Integrated Security = Sspi ; User ID = Mydomain \ myusername ; Password = Mypassword ;
Connect by IP Address
Data Source = 190.190.200.100, 1433 ; Network Library = Dbmssocn ; Initial catalog = Mydatabase ; User ID = Myusername ; Password = Mypassword ;
Connection of the specified Package Size

By default, the SQL server's Microsoft. NET Framework data provider sets the network package size to 8192 bytes. However, this is not necessarily the best. You can set the package size based on the appropriate package size, Packet size = Is to set the package size value

Server=Myserveraddress;Database=Mydatabase;User ID=Myusername;Password=Mypassword;Trusted_connection=False;Packet Size=4096;

Data shape connection mode

MS data shape Provider = Msdatashape ; Data Provider = Sqloledb ; Data Source = Myserveraddress ; Initial catalog = Mydatabase ; User ID = Myusername ; Password = Mypassword ;

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.