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 ;