To connect to a named instance on a static port, use Server= servername, port_number. The only protocol supported by the Linux and macOS drivers is tcp. For example, Server=tcp: servername ,12345. You can optionally specify the protocol and port to connect to the server. The above connection string would be the equivalent of specifying a connection string without the DSN keyword like: Driver=ODBC Driver 18 for SQL Server Server=tcp:localhost,1433 Encrypt=yes UID=my_username PWD=my_password To connect using the above DSN in a connection string, you would specify the DSN keyword like: DSN=MSSQLTest UID=my_username PWD=my_password # for the Microsoft ODBC driver on Linux or macOS # Port isn't a valid keyword in the odbc.ini file odbc.ini in your home directory) for a User DSN only accessible to the current user, or /etc/odbc.ini for a System DSN (administrative privileges required.) The following odbc.ini is a sample that shows the minimal required entries for a DSN: # To create a DSN, create (if necessary) and edit the file ~/.odbc.ini (. You can use a DSN to define connection string keywords under a DSN name that you can then reference in the connection string. ini file used to install the driver.ĭSNs are optional. The path to the driver library, which was specified in the template. The name you used when you installed the driver. The value passed to the Driver keyword can be one of the following: Instead, send a use database_name command to connect to the database before executing your queries. When connecting to a database that uses database mirroring (has a failover partner), do not specify the database name in the connection string.
0 Comments
Leave a Reply. |