The Easysoft ODBC-SQL Server Driver is installed on the computer where your applications are running. ODBC applications access ODBC drivers through the ODBC Driver Manager and a data source. The data source tells the Driver Manager which ODBC driver to load, which SQL Server instance to connect to and how to connect to it. This chapter describes how to create data sources, use DSN-less connections and configure the Easysoft ODBC-SQL Server Driver.
Before setting up a data source, you must have successfully installed the Easysoft ODBC-SQL Server Driver.
For Easysoft ODBC-SQL Server Driver installation instructions, see Installation.
This section describes how to configure the Easysoft ODBC-SQL Server Driver to connect to a SQL Server database by using a data source or a DSN-less connection string. The section assumes you are, or are able to consult with, a database administrator.
There are two ways to set up a data source to your SQL Server data:
By default, the Easysoft ODBC-SQL Server Driver installation creates a SYSTEM data source named [SQLSERVER_SAMPLE]. If you are using the unixODBC included in the Easysoft ODBC-SQL Server Driver distribution, the SYSTEM odbc.ini file is in /etc.
If you built unixODBC yourself, or installed it from some other source, SYSTEM data sources are stored in the path specified with the configure option --sysconfdir=directory. If sysconfdir was not specified when unixODBC was configured and built, it defaults to /usr/local/etc.
If you accepted the default choices when installing the Easysoft ODBC-SQL Server Driver, USER data sources must be created and edited in $HOME/.odbc.ini.
| To display the directory where unixODBC stores SYSTEM and USER data sources, type odbcinst -j. By default, you must be logged in as root to edit a SYSTEM data source defined in /etc/odbc.ini. |
You can either edit the sample data source or create new data sources.
Each section of the odbc.ini file starts with a data source name in square brackets [ ] followed by a number of attribute=value pairs.
| Attribute names in odbc.ini are not case sensitive. |
The Driver attribute identifies the ODBC driver in the odbcinst.ini file to use for a data source. The Easysoft ODBC-SQL Server Driver distribution includes two drivers:
When the Easysoft ODBC-SQL Server Driver is installed into unixODBC, entries for the standard driver (Easysoft ODBC-SQL Server) and the driver with SSL support (Easysoft ODBC-SQL Server SSL) are placed in odbcinst.ini.
For Easysoft ODBC-SQL Server Driver data sources, you need to include a Driver = Easysoft ODBC-SQL Server entry.
For Easysoft ODBC-SQL Server Driver with SSL Support data sources, you need to include a Driver = Easysoft ODBC-SQL Server SSL entry. For more information about configuring Easysoft ODBC-SQL Server Driver with SSL Support data sources, see Encrypting Connections to SQL Server.
To configure a SQL Server data source, in your odbc.ini file, you need to specify:
Driver = Easysoft ODBC-SQL Server
# To connect to the default instance, omit \my_instance_name.
Server = my_sqlserver_hostname\my_instance_name
User = my_domain\my_domain_user
If the SQL Server Browser or listener service is not in use at your site and you want to connect to an instance that is not listening on the default TCP port (1433), you also need to specify the port: For example, to connect to a SQL Server instance that is listening on port 1500, add this entry:
The following attributes may be set in the odbc.ini file:
| The name of the ODBC driver to use with this data source. To connect to a SQL Server 2000 or 2005 instance over an encrypted connection, set this attribute value to Easysoft ODBC-SQL Server SSL. Otherwise, set this attribute value to Easysoft ODBC-SQL Server. | |
| A single line of descriptive text that may be retrieved by some applications to describe the data source. | |
| The SQL Server instance that you want to connect to. To connect to the default SQL Server instance, type: where machinename is the name or IP address of the host where SQL Server is running. Note that if you are connecting to a SQL Server 2005 instance that is listening on an IPv6 address, set the IPv6 attribute to 1. To connect to a named instance, type: where instancename is the SQL Server instance. To connect to the default SQL Server Express named instance, type: | |
| If your SQL Server database is available on more than one SQL Server machine, you can define a primary server for the database and additional fallback database servers. By default, the Easysoft ODBC-SQL Server Driver will try to connect to the first server that you specify. If that server is unavailable the Easysoft ODBC-SQL Server Driver will try to connect to the next server in the list and so on. Use the format: Server =primaryserver[:port] [,fallbackserver[:port]...]
Server = sqlsrvhostA,sqlsrvhostB,sqlsrvhostC:1583 Connection attempts continue until either a connection is successfully made or all the servers in the list have been tried once. Note that your SQL Server login (as specified by User and Password) needs to be valid on each SQL Server machine in the list. The SQL Server login must have permission to access the database on each SQL Server machine. If you want to balance the load between database servers, configure the driver to randomly choose the database server it connects to. To do this, set the ClientLB attribute to 1. | |
| The TCP port that SQL Server is listening on. If you are connecting to a default instance that is listening on port 1433, the Port setting can be omitted. If the SQL Server Browser or the SQL Server 2000 listener service is running, the Easysoft ODBC-SQL Server Driver will automatically detect the port number and the Port setting can be omitted. By default, named instances of SQL Server use dynamic ports, which means that an available port is assigned when the instance starts. If a SQL Server instance is listening on a dynamically allocated port number, you must omit the Port setting and let the Easysoft ODBC-SQL Server Driver use the browser or listener to detect the port number. If the SQL Server Browser or listener is not running at your site, your database administrator will have configured each SQL Server instance to listen on a specific TCP port. You need to specify this port with the Port setting. If your database administrator has hidden the SQL Server instance from the SQL Server Browser or listener, you need to specify the port number of the hidden instance. If your database administrator has configured the SQL Server instance to listen on multiple ports, use the Port setting to specify the appropriate port number from the available alternatives. | |
| The SQL Server login name to use when connecting to SQL Server. If the SQL Server instance uses Windows Authentication (also known as trusted connections), the Windows user name to use to authenticate the connection. Use this format:
If the SQL Server instance permits SQL Server Authentication, you can also specify a SQL Server user name. To specify the login name in the connection string, use UID rather than User. For more information about specifying Easysoft ODBC-SQL Server Driver attributes in the connection string, see DSN-less Connections. | |
| The password for the login name specified by User. To specify the login password in the connection string, use PWD rather than Password. | |
| The default database to use for the connection. If you omit this attribute, the connection uses the default database defined for the login in SQL Server. The default database for users who do not have their own SQL Server login depends on the local group on the SQL Server machine that they belong to. The default database for members of the local Administrators group is the one defined for the BUILTIN\Administrators login. The default database for members of the local Users group is the one defined for the BUILTIN\Users login (SQL Server 2005 Express Edition only). If the database does not exist or the login does not have permission to access the database, the connection will fail. Note that using the default database for the login ID is more efficient than specifying a default database in the ODBC data source. | |
| When ON (set to 1), QUOTED_IDENTIFIERS is set to ON for the connection. SQL Server will then follow the SQL-92 rules regarding the use of quotation marks in SQL Statements. Double quotes can only be used for identifiers, such as column and table names. Character strings must be enclosed in single quotes: FROM "Customer and Suppliers by City" If a single quotation mark is part of the literal string, it can be represented by two single quotation marks. When OFF, QUOTED_IDENTIFIERS is set to OFF for the connection. SQL Server then follows the legacy Transact-SQL rules regarding the use of quotation marks. Identifiers cannot be quoted and must follow all Transact-SQL rules for identifiers. Literals can be delimited by either single or double quotation marks. For more information about the QUOTED_IDENTIFIERS option, see the SQL Server Transact-SQL documentation. | |
| When ON (set to 1), the ANSI_NULLS, ANSI_WARNINGS, and ANSI_PADDING options are set to ON for the connection. When ANSI_NULLS is ON, SQL Server enforces ANSI rules for handling NULL comparisons. The ANSI syntax IS NULL or IS NOT NULL must be used for all NULL comparisons. For example: The Transact-SQL syntax = NULL and <> NULL are not supported. When ANSI_NULLS is OFF, the Equals (=) and Not Equal To (<>) comparison operators must be used to make comparisons with NULL and nonnull values in a table. When ANSI_WARNINGS is ON, SQL Server generates warning messages for conditions that violate ANSI rules but do not violate the rules of Transact-SQL. For example, SQL Server will generate error and warning messages for divide-by-zero errors, string too large for database column errors and when NULL values are encountered when using aggregate functions. When SET ANSI_WARNINGS is OFF, these errors and warnings are not raised. When ANSI_PADDING is ON, trailing blanks on varchar values and trailing zeroes on varbinary values are not automatically trimmed. For more information about the ANSI_NULLS, ANSI_WARNINGS, and ANSI_PADDING options, see the SQL Server Transact-SQL documentation. | |
| The national language to use for SQL Server system messages. Use this format: where language is one the language aliases contained in the sys.syslanguages table. If no language is specified, the connection uses the default language specified for the login on the server. | |
| The name SQL Server uses to identify the application that connects using this data source. For example, the following entry identifies an application as isql: The default value is ODBC. SQL Server stores the application name in the master.dbo.sysprocesses column program_name. The name is returned by the APP_NAME function. | |
| When ON (set to 1), multiple active result sets (MARS) are enabled on the connection if the server is SQL Server 2005. MARS allows applications to have more than one pending request per connection, and in particular, to have more than one active default result set per connection. Applications can execute other statements (for example, INSERT, UPDATE, DELETE, and stored procedure calls) while result sets are open. For example, an application might retrieve unprocessed items from an Orders table and then, while looping through the active result set, use an UPDATE statement to mark each order as processed. For non-MARS connections (MARS_Connection turned OFF) and earlier versions of SQL Server, applications cannot maintain multiple active statements on a connection. Applications that attempt to do this fail with the error "connection is busy with results of another hstmt". The application has to process or cancel all result sets from one batch before it can execute any other batch on that connection. Note that server-side cursors can be used to work around this limitation. There is a performance penalty associated with server-side cursors however. For more information about MARS, see the Microsoft article Multiple Active Result Sets (MARS) in SQL Server 2005. | |
| When ON (set to 1), the Easysoft ODBC-SQL Server Driver preserves cursors when SQLEndTran commits or rolls back a transaction. By default, PreserveCursor is OFF, which means that cursors are closed when a transaction is committed or rolled back by using SQLEndTran. This behaviour can also be configured by setting SQL_COPT_SS_PRESERVE_CURSORS with SQLSetConnectAttr. For more information and a code sample, see SQL_COPT_SS_PRESERVE_CURSORS. | |
| The workstation ID. The default value is the host name of the machine where the ODBC application is running. SQL Server stores the workstation ID in the master.dbo.sysprocesses column hostname. The ID is returned by sp_who and the HOST_NAME function. | |
| Set to Version7 to 1 if you are connecting to a SQL Server 7.0 database. When initiating the connection, the Easysoft ODBC-SQL Server Driver tries to discover the version of the SQL Server instance. Setting Version7 to 1 reduces the number of steps in the discovery process for SQL Server 7.0 databases. This results in a slightly quicker connection time. | |
| When OFF (set to 0), the Easysoft ODBC-SQL Server Driver returns a varchar(max) column as a SQL_VARCHAR with a zero length, which means the maximum size is unlimited. Some applications may interpret this to mean that the column size is zero bytes rather than unlimited and allocate a buffer that is too small for the column data. To work around this, try setting VarMaxAsLong to 1. When ON (set to 1), the Easysoft ODBC-SQL Server Driver returns a varchar(max) column as a SQL_LONGVARCHAR. | |
| Whether the Easysoft ODBC-SQL Server Driver tries to balance the load between the servers specified by the Server setting. The ClientLB setting only has an effect if you specify a primary server and additional fallback servers with Server. When ClientLB is ON (set to 1), the Easysoft ODBC-SQL Server Driver randomly selects a server to connect to. If the server is unavailable, the Easysoft ODBC-SQL Server Driver then moves sequentially through the list of other servers. When ClientLB OFF (set to 0, the default), the Easysoft ODBC-SQL Server Driver tries to connect to the servers in the order that they are defined in. (Primary server first and then each additional fallback server.) You specify a primary server (sqlsrvhostA) and two fallback servers (sqlsrvhostB and sqlsrvhostC): Server = sqlsrvhostA,sqlsrvhostB,sqlsrvhostC:1583 When ClientLB is ON, the Easysoft ODBC-SQL Server Driver will randomly choose a server to connect to. If, for example, the driver tries to connect to sqlsrvhostB first, it will then try to connect to sqlsrvhostC (if sqlsrvhostB is unavailable) and sqlsrvhostA (if sqlsrvhostC is unavailable). When ClientLB is OFF, the Easysoft driver will try to connect to sqlsrvhostA and then sqlsrvhostB (if sqlsrvhostA is unavailable) and finally sqlsrvhostC (if sqlsrvhostB is unavailable). | |
| Use Failover_Partner to specify the current mirror database server. If the initial connection to the principal database server fails, the Easysoft ODBC-SQL Server Driver will attempt a connection to the server specified by Failover_Partner. For more information about database mirroring, see Database Mirroring. | |
| When ON (set to 1), the Easysoft ODBC-SQL Server Driver describes the UNIQUEIDENTIFIER data types as CHAR rather than GUID. This is a workaround for applications such as Oracle's HSODBC that do not recognise UNIQUEIDENTIFIER types and therefore fail to return data from tables containing these column types. | |
| When ON (set to 1), the Easysoft ODBC-SQL Server Driver describes IMAGE and TEXT data types as VARBINARY and VCHAR. This is a workaround for applications such as Oracle's HSODBC that cannot handle IMAGE and TEXT types and therefore fail to return data from tables containing these column types. | |
| The maximum size in bytes that the Easysoft ODBC-SQL Server Driver returns for IMAGE, NTEXT, TEXT, NVARCHAR(MAX), VARBINARY(MAX) and VARCHAR(MAX) columns. Use LimitLong to restrict the size returned by the driver when describing these data types. By default, LimitLong is OFF (set to 0), which means that the Easysoft ODBC-SQL Server Driver returns the maximum size for NTEXT and TEXT columns. For MAX data types, LimitLong's default value means that the returned column size is SQL_SS_LENGTH_UNLIMITED (0). This value indicates that the column size is "unlimited". | |
| When ON (set to 1), the Easysoft ODBC-SQL Server Driver converts UCS-2 encoded data to UTF-8 and vice versa. This enables applications running on UTF-8 platforms to work with Unicode data stored in NCHAR, NVARCHAR and NTEXT columns. SQL Server uses UCS-2 to encode data in NCHAR, NVARCHAR and NTEXT columns. If your application expects UTF-8 encoded data, it will be unable to process Unicode data stored in NCHAR, NVARCHAR and NTEXT columns. To work around this, add this line to your ODBC data source. By default, ConvToUtf is OFF (set to 0). We ran OpenOffice.org 2.0 on Ubuntu from a shell in which the LANG environment was set to en_GB.UTF-8. With ConvToUtf set to 0, we connected to a SQL Server data source in OOo Base and ran this SQL: select CompanyName from Suppliers where SupplierID = 29 SQL Server stores data in the CompanyName column as a UCS-2 encoded NVARCHAR type. The results for this query should be: Instead, we got these results: The ? symbols indicate that application was unable to convert the character from the server encoding scheme to the client encoding scheme. | |
| In OOo Writer, we used the Insert > Special Character command to insert ê and é into a new document. We did this to show that OpenOffice.org running on this system and environment was capable of rendering these two characters. We then saved the document as a Text file and ran the following command at the shell prompt: ooo_chars.txt: Unicode text, UTF-8 The file command's output indicates that the encoding scheme OpenOffice was using is UTF-8. We set ConfToUTF to 1 and reconnected to the data source in Base. Running the same query returned the expected results. This is because the Easysoft ODBC-SQL Server Driver converts the UCS-2 encoded data to UTF-8, the encoding OpenOffice expects. We created a SQL file named insert-northwind-shipper.sql on a Ubuntu machine: -- Insert new record into the Northwind shippers table INSERT INTO Shippers (CompanyName, Phone) VALUES (N'♦ Diamond Shipping', '(11) 555-2167'); To create the file, we used the Vi IMproved (vim) text editor from a shell in which the LANG environment was set to en_GB.UTF-8. To insert the ♦ character in vim, we typed CTRL+V u2666. (u+2666 is the Unicode code point for this character.) The N prefix before the INSERT statement value tells SQL Server that the string contains a Unicode character. To confirm that the SQL file was UTF-8 encoded, we ran the file command: | |
| In the same shell, we used insert-northwind-shipper.sqlas an input file to isql: /usr/local/easysoft/unixODBC/bin/isql -v SQLSERVER_SAMPLE < insert-northwind-shipper.sql The SQLSERVER_SAMPLE data source connects to a SQL Server instance that serves the Northwind database. In the data source, ConfToUTF was set to 1. The command's output confirmed that the new record had been successfully inserted and that the Ubuntu machine was capable of rendering the ♦ character: SQL>--+---------------------+----------------------+ +-----+------------------------+-------------------------+ | 1 | Speedy Express | (503) 555-9831 | | 2 | United Package | (503) 555-3199 | | 3 | Federal Shipping | (503) 555-9931 | | 4 | ♦ Diamond Shipping | (11) 555-2167 | +------+-----------------------+-------------------------+ ConvToUTF has no effect on values bound to statement parameters (SQLBindParameter). | |
| When ON (set to 1), the Easysoft ODBC-SQL Server Driver describes NVARCHAR and NCHAR data types as VARCHAR and CHAR. This is a workaround for applications such as Oracle's HSODBC that do not recognise NVARCHAR and NCHAR types and therefore fail to return data from tables containing these column types. | |
| Whether to use Windows or SQL Server authentication to validate the connection. | |
| The Windows domain that the user specified with User belongs to. If the user belongs to the same domain as the one that the SQL Server machine is in, you can omit Trusted_Domain. The Easysoft ODBC-SQL Server Driver automatically detects the domain in this case. If you specify a Domain with Trusted_Domain, set Trusted_Connection to 1 and omit the domain from User. For example: | |
| If the server your SQL Server machine validates Windows logins with uses NTLMv2 authentication, set NTLMv2 to 1. Otherwise, leave NTLMv2 set to its default value 0 (OFF). | |
| Set IPv6 to 1 when connecting to a SQL Server 2005 instance that is listening on an IPv6 address. By default, IPv6 is OFF (set to 0), which means that the Easysoft ODBC-SQL Server Driver assumes that the target SQL Server instance is listening on an IPv4 address. For more information about IPv6, see Connecting to SQL Server 2005 by Using IPv6. | |
| The number of milliseconds to wait for any request on the connection to complete before returning to the application. After the initial connection to the SQL Server machine has been established, the Easysoft ODBC-SQL Server Driver will wait num milliseconds each time it needs a response from SQL Server. If no response is received from SQL Server before the timeout expires, the Easysoft ODBC-SQL Server Driver returns the error Timeout expired. The default value 0 means that no connection timeout is applied by the Easysoft ODBC-SQL Server Driver. A timeout set by calling SQLSetConnectAttr with the SQL_ATTR_CONNECTION_TIMEOUT connection attribute will override ConnectionTimeout. | |
| The number of milliseconds to wait for a TCP connection to the SQL Server machine to be established before returning to the application. When you define a timeout, the initial connection phase lasts for num milliseconds. If the Easysoft ODBC-SQL Server Driver is unable to connect to the target SQL Server machine before the timeout expires, it returns the message Connection timeout expired. Note that if you specify a named instance in the Server attribute value, the driver returns a different timeout message: Failed to get datagram from socket. The default value 0 means that no initial connection timeout is applied by the Easysoft ODBC-SQL Server Driver. The Easysoft ODBC-SQL Server Driver classes the connection phase as obtaining the IP address of the SQL Server machine and connecting to it. This means that if you specify the Server attribute value as a machine name rather than an IP address, your system resolver library will be used (possibly examining /etc/hosts or doing a DNS query). On some operating systems, gethostbyname(), the call used to resolve a machine name into an IP address, cannot be interrupted and the connection timeout will not work. If this is a problem for you, either specify the SQL Server machine as an IP address or tell your resolver library to consult /etc/hosts before DNS and place an entry in /etc/hosts. A timeout set by calling SQLSetConnectAttr with the SQL_ATTR_LOGIN_TIMEOUT connection attribute will override LogonTimeout. |
The Easysoft ODBC-SQL Server Driver must be able to find the following shared objects, which are installed during the Easysoft ODBC-SQL Server Driver installation:
By default, this is located in /usr/local/easysoft/unixODBC/lib.
By default, this is located in /usr/local/easysoft/lib.
By default, this is located in /usr/local/easysoft/lib.
By default, this is located in /usr/local/easysoft/lib.
For more information about libestdscrypt.so, see Windows Authentication.
You may need to set and export LD_LIBRARY_PATH, SHLIB_PATH or LIBPATH (depending on your operating system and run-time linker) to include the directories where libodbcinst.so, libeslicshr.so and libessupp.so are located.
| The shared object file extension (.so) may vary depending on the operating system (.so, .a or .sl). |
The isql query tool lets you test your Easysoft ODBC-SQL Server Driver data sources.
To test the Easysoft ODBC-SQL Server Driver connection
1. Change directory into /usr/local/easysoft/unixODBC/bin.
2. Type ./isql -vdata_source, where data_source is the name of the target data source.
If you are unable to connect, see Troubleshooting Database Connection Problems for help on solving some common connection problems.
3. At the prompt, type an SQL query. For example:
Type help to return a list of tables:
This section lists some common connection problems and their solutions.
Check the Server attribute in your data source specifies a valid machine name or IP address. Check that the machine name can be looked up by using DNS or is present in /etc/hosts. Check that you are on the same network as the target host by pinging the machine:
If ping times out or fails, then either the DNS lookup is not working properly or there is some other networking or routing issue that needs to be resolved. Contact your network administrator.
Check that the SQL Server instance that you are trying to connect to is running.
If the SQL Server Browser or listener service is running, you can use tdshelperto display a list of all the running SQL Server instances on your network. On the machine where the Easysoft ODBC-SQL Server Driver is installed:
cd /usr/local/easysoft/sqlserver/bin
On the SQL Server machine, "SQL Server <instance>" will be listed in output of the net start command, if the SQL Server instance is running.
If SQL Server is listening on a fixed TCP port, check that you can use telnet to connect to the port that you have specified in the data source:
where hostname is the host name or IP address of the machine where SQL Server is running and port is the port number that you have specified with the Port attribute. If the SQL Server instance is listening on this port, you will see output similar to:
To exit from telnet, type CTRL-] and then quit.
If you do not see this output or a "Connection refused" error displays, SQL Server is not listening on the specified port. Contact your database administrator for the correct SQL Server port.
If you are using the correct port but are unable to connect with telnet, the SQL Server instance may not allow remote TCP/IP connections. See Client unable to establish connection: Server not configured for TCP connection.
The TCP/IP protocol must be enabled in the instance that you are trying to connect to.
In the SQL Server Configuration Manager, in the list of network protocols for the instance, the status for TCP/IP must be set to "Enabled".
By default, SQL Server 2005 does not allow remote connections, which means that the default setting for TCP/IP is "Disabled".
The Easysoft ODBC-SQL Server Driver uses the SQL Server Browser or the SQL Server 2000 listener service to find out what TCP port SQL Server is listening on. If the SQL Server Browser or listener service is not running and active, the Easysoft ODBC-SQL Server Driver will be unable to open a connection for this purpose and the "Failed to get datagram from socket" error displays.
On the machine where the Easysoft ODBC-SQL Server Driver is installed, if you run /usr/local/easysoft/tdshelper -i and see no SQL Server instances listed in the output, the browser or listener may not be running.
On the SQL Server machine, "SQL Server Browser" will be listed in output of the net start command, if the SQL Server Browser is running. If net start shows that the SQL Server Browser service is running, the service may not be active. In the SQL Server Configuration Manager, the Active option must be set to "Yes" in the Advanced SQL Server Browser property tab. (The SQL Server Browser service must be restarted before any change to this setting takes effect.)
If you are connecting to SQL Server through a firewall, the firewall needs to allow connections through:
If UDP port 1434 is not open, the firewall will block the connection when the Easysoft ODBC-SQL Server Driver attempts to discover the SQL Server port and the 'Failed to get datagram from socket' will display.
Because the SQL Server Browser or listener accepts unauthenticated UDP requests, it may have been turned off as a security measure, and your database administrator will have configured each SQL Server instance to listen on a specific TCP port. You need to specify this port number with the Port setting. For example, if SQL Server is listening on port 1500, add this line to the data source in odbc.ini:
The "Failed to get datagram from socket" error also displays if you try to connect to a hidden SQL Server instance. You need to specify the port that the hidden instance is listening even though the SQL Server Browser or listener may be running.
Check that the User and Password attributes for the data source in the odbc.ini specify a valid Windows user name and password.
This error also displays if you try to connect to SQL Server with a SQL Server user name and password but SQL Server's authentication mode is set to Windows Authentication only. To connect by using a SQL Server account, the security mode for the SQL Server instance must be changed to mixed (both SQL Server and Windows authentication are enabled).
To enable mixed mode, your database administrator must set the SQL Server security property Server Authentication to SQL Server and Windows Authentication mode. Note that Microsoft recommend that Windows authentication is used to connect to SQL Server whenever possible.
Check that the User and Password attributes for the data source in the odbc.ini specify a valid SQL Server user name and password.
This error also displays if you try to connect to SQL Server with a valid Windows user name and password but no corresponding SQL Server login exists. For example, SQL Server Setup creates a login named BUILTIN\Administrators that allows members of the local Administrators Windows group to access SQL Server. As a security measure, the database administrator may delete this login and members of this group will then need individual SQL Server login accounts to access SQL Server.
Ask your database administrator to create a SQL Server login for you that uses Windows authentication to validate your connection details.
The Easysoft ODBC-SQL Server Driver distribution includes the diagnostic program tdshelper. tdshelper lets you:
The Easysoft ODBC-SQL Server Driver installation script installs tdshelper in /usr/local/easysoft/sqlserver/bin.
To use tdshelper, you may need to tell the dynamic linker where to find the shared objects that tdshelper depends on. The shared objects are in /usr/local/easysoft/lib.
To do this, set and export the appropriate environment variable for your linker and platform.
| Some versions of HP-UX. For example: | |
| Linux, Solaris, some versions of HP-UX. For example: | |
tdshelper has the following command line:
The password for the SQL Server login name specified with the -u option.
The number of probe packets to send when searching for SQL Server instances. The default is 5.
List the databases that are available to the login name specified by -u in the SQL Server instance specified by -s. The default database for the login is shown first in the command output.
List the languages that SQL Server system messages are available in. To retrieve the languages, you also need to specify a SQL Server instance (-s) and login (-u -a). The default language for the login is shown first in the command output.
The TCP port that the SQL Server instance specified with the -s option is listening on.
If you omit the port and are connecting to a named instance, tdshelper will use the SQL Server Browser or listener to detect the port. If you omit the port and are connecting to the default instance, tdshelper will try to connect to port 1433.
Search for SQL Server instances on the network. For each instance found, the command's output displays:
Search for SQL Server instances on the network. The output is more concise than that produced by the -p option. The output lists each instance found using the format machinename\instancename. Default instances are listed as machinename.
The SQL Server instance to connect to. To test the connection to the default SQL Server instance, replace instance with the host name or IP address of the machine where the instance is running. To test the connection to a named instance, replace instance with machinename\instance, where:
If the SQL Server Browser or listener service is not running and the instance is not listening on the default port 1433, specify the port with -p.
To test database authentication, you also need to specify a valid SQL Server login name and password for the instance with -u and -a.
A valid SQL Server login name for the instance specified with -s. If you usually connect to SQL Server through your Windows account, type your Windows user name. Use the format domain\username, where domain is the name of the Windows domain to which username belongs. Otherwise, specify a valid SQL Server user name. Use -a to specify the password.
The database to connect to. Use -s to specify the instance that is serving the database. Use -u and -a to specify a valid SQL Server login and password for the database.
Display extra status and diagnostic information. Use this option with -s to diagnose connection problems.
Specify this option if you are connecting to a SQL Server instance that is listening on an IPv6 address. For example, ./tdshelper -6 -s 'ABCD:EF12::3456\SQLEXPRESS' -v
To connect to a SQL Server instance, you need this information:
tdshelper lets you confirm that your connection settings are valid before you use the information in an Easysoft ODBC-SQL Server Driver data source. If the SQL Server Browser or listener is running, you can also use tdshelper to verify that the SQL Server instance is running and visible from the machine where the Easysoft ODBC-SQL Server Driver is installed.
1. cd /usr/local/easysoft/sqlserver/bin
2. If the SQL Server Browser or listener is running, check that your SQL Server instance is running by typing the following command. Otherwise, skip this step.
If the instance is running, it will be listed in the tdshelper output. In the following example output, the default SQL Server instance is running on the machine MYSQLSERVER2000HOST; the default named SQL Server Express instance is running on the machine MYSQLEXPRESSHOST; a named SQL Server instance is running on the machine MYSQLSERVER2005HOST:
ServerName MYSQLSERVER2000HOST Port 1433 (Default)
ServerName MYSQLEXPRESSHOST\SQLEXPRESS Port 2777
ServerName MYSQLSERVER2005HOST\MYINSTANCEI Port 1510
The output also shows the TCP port that each instance is listening on.
./tdshelper -smachinename -nport -v
Replace machinename with the host name of the SQL Server machine. Replace port with the TCP port on which the instance is listening. For example, tdshelper -s MYSQLSERVER2000HOST -n 1433 -v.
./tdshelper -s 'machinename\instance' -nport -v
Replace machinename with the host name of the SQL Server machine and instance with the instance name. Replace port with the TCP port on which the instance is listening. For example, tdshelper -s 'MYSQLSERVER2005HOST\MYINSTANCEI' -n 1510 -v.
If tdshelper can connect to SQL Server, you will see output similar to this:
tdshelper: connecting to MYSQLSERVER2000HOST on port 1433
tdshelper: succesfully opened connection
When configuring an Easysoft ODBC-SQL Server Driver data source to connect to this instance, use the value you specified with the -s option for the Server attribute value.
If tdshelper is unable to connect and displays a "Connection refused" error, the SQL Server instance may not be running, be listening on the port you specified or allow remote TCP/IP connections. For more information, see Client unable to establish connection: OS Error: 'Connection refused' and Client unable to establish connection: Server not configured for TCP connection.
4. To check that you can access the instance with your SQL Server login name and password, use the -u and -a options.
If you usually connect to SQL Server through your Windows account, specify your Windows user name with -u. Use the format domain\username, where domain is the name of the Windows domain to which username belongs. Otherwise, specify a valid SQL Server user name.
Specify the password for your user name with -a.
./tdshelper -s 'MYSQLSERVER2005HOST\MYINSTANCEI' -u 'mydomain\mywindowsuser' -a mywindowspassword -v
/tdshelper -s MYSQLSERVER2000HOST -u mysqlserveruser -a mysqlserverpassword -v
If tdshelper can successfully access the SQL Server instance with your user name and password, the output will contain the following line:
tdshelper: succesfully logged into server with diagnostic records
When configuring an Easysoft ODBC-SQL Server Driver data source to connect to this instance, the User and Password attribute values should be the same as the values you specified with the -u and -a options.
If tdshelper is unable to connect and displays a "Login failed for user ''. The user is not associated with a trusted SQL Server connection." error, check that you specified a valid Windows user name and password. If tdshelper fails with an "Login failed for user 'myuser'." error, check that you specified a valid SQL Server user name and password.
For information about other situations in which these errors display, see Login failed for user ''. The user is not associated with a trusted connection and Login failed for user 'myuser'..
In addition to using a data source, you can also connect to a database by using a DSN-less connection string of the form:
SQLDriverConnect(..."DRIVER={Easysoft ODBC-SQL Server};
Server=server;UID=user;PWD=password;
where server is the SQL Server instance that you want to connect to, user and password are a valid SQL Server login and password and port is the TCP port that SQL Server is listening on. You need to use the Easysoft ODBC-SQL Server DRIVER keyword to identify the Easysoft ODBC-SQL Server Driver.
Other Easysoft ODBC-SQL Server Driver attribute settings, as described in Setting Up Data Sources, can be added to the connection string using the same PARAMETER=value; format. For example, the following connection string changes the default database with the Database attribute:
"DRIVER={Easysoft ODBC-SQL Server};Server=myhost\\SQLEXPRESS;UID=mydomain\\myuser;PWD=mypassword;Port=1500;Database=Sales;"
| Copyright Notice |