MySQL
Standard
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
Specifying TCP port
Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
Multiple servers
Use this to connect to a server in a replicated server configuration without concern on which server to use.
Server=serverAddress1, serverAddress2, serverAddress3;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
Using encryption (old)
This one activates SSL encryption for all data sent between the client and server. The server must have a certificate installed.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Encrypt=true;
Using encryption (new)
Use SSL if the server supports it, but allow connection in all cases
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;SslMode=Preferred;
Force encryption
Always use SSL. Deny connection if server does not support SSL.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;SslMode=Required;
SSL with a file-based certificate
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;SSL Mode=Required;CertificateFile=C:\folder\client.pfx;CertificatePassword=pass;
SSL with a personal store-based certificate
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;SSL Mode=Required;Certificate Store Location=CurrentUser;
SSL with a thumbprint specific personal store-based certificate
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;SSL Mode=Required;Certificate Store Location=CurrentUser;Certificate Thumbprint=479436009a40f3017a145cf8479e7694d7aadef0;
Disallow batches
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;AllowBatch=False;
Allow User Variables
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;AllowUserVariables=True;
Invalid DateTime's 1
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;AllowZeroDateTime=True;
Invalid DateTime's 2
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;ConvertZeroDateTime=True;
Disable transaction participation
The use of auto enlist transactionscope (default behaviour) could cause trouble in medium trust environments.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;AutoEnlist=False;
Skip parameter checks for stored routines
Default behaviour is that parameters for stored routines (stored procedures) are checked against the server
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;CheckParameters=False;
Skip parameter type and order matching for stored procedures
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;UseProcedureBodies=False;
Use Table Caching
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;tablecache=true;DefaultTableCacheAge=30;
Count changed rows instead of found rows
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;UseAffectedRows=True;
Compress network communication between client and server
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;UseCompression=True;
Log inefficient database operations
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;UseUsageAdvisor=True;
Enable performance counters
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;UsePerformanceMonitor=True;
Connection Pooling
From version 6.2 idle connections are removed from the pool, freeing resources on the client (sockets) and the server (sockets and threads). Do not manually keep (global) connections and open close. Keep connection object creation and disposal as tight as possible, this might be counterintuitive but pooling mechanisms will take care of caching well and your code will be cleaner.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Pooling=True;
Connection Pool size
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;MinimumPoolSize=10;maximumpoolsize=50;
Disable connection pooling
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Pooling=False;
Connection state reset when obtained from pool
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;ConnectionReset=True;
Recycle connections in pool
This is useful in load balancing scenarios when available servers change you don't want 100 constant connections in the pool pointing to only one server.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;ConnectionLifeTime=300;
Do not update server settings on connections in pool
A connection might be long lived in the pool, however the connections server settings are updated (SHOW VARIABLES command) each time returned to the pool. This makes the client use of the connection object up to date with the correct server settings. However this causes a round trip and to optimize pooling performance this behaviour can be turned off.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;CacheServerProperties=True;
Use Windows authentication
Server=myServerAddress;Database=myDataBase;IntegratedSecurity=yes;Uid=auth_windows;
Keep TCP Sockets alive
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Keepalive=10;
Use BINARY(16) GUIDs
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;OldGuids=True;
Disable Stored procedure cache
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;ProcedureCacheSize=0;
Allow square brackets around symbols (instead of backticks)
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;sqlservermode=True;
Specifying default command timeout
Use this one to specify a default command timeout for the connection. Please note that the property in the connection string does not supercede the individual command timeout property on an individual command object.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;default command timeout=20;
Specifying connection attempt timeout
Use this one to specify the length in seconds to wait for a server connection before terminating the attempt and receive an error.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Connection Timeout=5;
Inactivating prepared statements
Use this one to instruct the provider to ignore any command prepare statements and prevent corruption issues with server side prepared statements.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Ignore Prepare=true;
Specifying network protocol
Use this one to specify which network protocol to use for the connection.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Protocol=socket;
Shared memory protocol
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Protocol=memory;Shared Memory Name=MYSQL;
Named pipes protocol
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Protocol=pipe;PipeName=mypipename;
Named pipes alternative
Server=myServerAddress;Port=-1;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
Unix socket connection
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Protocol=memory;Shared Memory Name=MYSQL;
Specifying character set
Use this one to specify which character set to use to encode queries sent to the server.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;CharSet=utf8;