AnyDAC
ContentsIndexHome
PreviousUpNext
Connect to Microsoft SQL Server

Describes how to connect to Microsoft SQL Server.

Group
Links
Supported versions

The AnyDAC native driver supports Microsoft SQL Server Standard and Express editions version 2000 and higher, and Microsoft SQL Azure. See Connect to Microsoft SQL Server Compact Edition for an explanation of how to connect to Microsoft SQL Server Compact Edition. 

 

Windows client software

AnyDAC requires one of the Microsoft SQL Server x86 or x64 ODBC drivers to be installed on the workstation:

  • SQL Server ODBC driver as the connectivity for SQL Server 2000. Most probably, the ODBC driver is already installed on your workstation. If not, see details.
  • SQL Native Client as the connectivity for SQL Server 2000 and 2005. We strongly recommend that you have SQL Native Client installed, if your application has to work with SQL Server 2005. See Microsoft SQL Server Native Client.
  • SQL Server Native Client NN.N as the connectivity for SQL Server 2000, 2005, 2008, 2012 and SQL Azure. We strongly recommend that you have SQL Server Native Client NN.N installed, if your application has to work with SQL Server 2008, 2012 or SQL Azure. See Microsoft SQL Server 2008 Native Client.
  • SQL Server Native Client 11.0 as the connectivity for LocalDB.

Note: SQL Server Native Client 10.0 (SQL Server 2008) may fail to call a stored procedure, when connected to SQL Server 2000. The symptom of this issue is the error message "Incorrect Syntax near to {". In this case use ODBC driver from SQL Server 2000 or 2005 distribution. 

When the SQL Server ODBC driver has not been properly installed, you will get an exception when you try to connect: 

 

[AnyDAC][Phys][ODBC][Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

 

Mac OS X client software

AnyDAC requires:

  • the UnixODBC (libodbc.dylib) x86 ODBC driver manager library;
  • the FreeTDS (libtdsodbc.so) x86 ODBC driver.

FreeTDS may be got from CVS into some folder in your home directory (more 1) (more 2). To install FreeTDS on Mac OS X use the commands: 

 

cvs -z3 -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds checkout -P freetdsc
cd freetds
./autogen.sh
./configure --with-tdsver=8.0 --with-unixodbc=/usr/local
make
sudo make install
echo [FreeTDS] > tds.driver.template
echo Description=v0.82 with protocol v8.0 >> tds.driver.template
echo Driver=/usr/local/lib/libtdsodbc.so >> tds.driver.template
odbcinst -i -d -f tds.driver.template

 

Note, you may need additionally to install gawk utility. At this point you can configure a ODBC DSN or test AnyDAC connection. 

Note, FreeTDS ODBC driver is not that efficient and stable as the original Microsoft ODBC driver. 

 

Driver linkage

To link the driver:

 

Connection definition parameters

To connect to the Microsoft SQL Server DBMS, most applications will need to specify DriverID, Server, Database, OSAuthent, User_Name and Password

 

DriverID=MSSQL  

Parameter 
Description 
Example value 
Server 
Name of a server running SQL Server on the network. The value must be either the name of a server on the network, or the name of a SQL Server Client Network Utility advanced server entry.
When you connect to the SQL Azure, you have to prepend server name with "tcp:" prefix.
Note: The alternative TPC/IP port may be specified after a server name, separated by the comma. 
  • 127.0.0.1\SQLEXPRESS
  • SrvHost, 4000
  • tcp:nasdfert6.database.windows.net
 
Port 
Only for Mac OS X. Specifies the port where SQL Server is listening.
For Windows platform the port may be specified after a comma in the Server parameter value. Eg Server=host, port. The default port is 1433. 
 
Database 
Name of the default database for the connection. If Database is not specified, the default database defined for the login is used. 
Northwind 
OSAuthent 
Controls authentication mode:
  • Yes - use windows authentication.
  • No - DBMS authentication. This is default value.
 
No 
User_Name 
The SQL Server login name, if OSAuthent=No.
When you connect to the SQL Azure, you have to append "@<server>" suffix to your user name. 
  • sa
  • addemo@nasdfert6
 
Password 
The SQL Server login password, if OSAuthent=No.
Note, the passwords with both '{' and '}' are not supported. 
 
Network 
Name of a network library dynamic-link library. The name need not include the path and must not include the .dll file name extension. 
dbnmpntw 
Address 
Network address of the server running an instance of SQL Server. Address is usually the network name of the server, but can be other names such as a pipe, or a TCP/IP port and socket address. 
 
MARS 
Controls the MARS - multiple active result sets support in a connection:
  • Yes - MARS is enabled for a connection. This is default value.
  • No - MARS is disabled.
The MARS is a feature supported by SQL 2005 and higher. It is not supported by SQL Azure. The enabled MARS may lead to fetch performance degradation. Please, read this for more details. 
No 
Workstation 
Workstation ID. Typically, this is the network name of the computer on which the application resides (optional). If specified, this value is stored in the master.dbo.sysprocesses column hostname and is returned by sp_who and the Transact-SQL HOST_NAME function. 
Bookkeeper1
 
Language 
SQL Server language name (optional). If connecting to a SQL Server with multiple languages, Language specifies which set of messages are used for the connection. 
 
Encrypt 
Controls the network traffic encryption:
  • Yes - network traffic will be encrypted.
  • No - no encryption is used. This is default value.
 
Yes 
LoginTimeout 
Controls the amount of time in seconds an application waits for a connection attempt to timeout while waiting to establish a connection. 0 specifies an infinite wait (default value). 
30 
VariantFormat 
Controls SQL_VARIANT data type representation:
  • String - values will be represented as dtWideString. This is default value.
  • Binary - values will be represented as dtByteString.
 
Binary 
ExtendedMetadata 
Controls extended describing of the query result sets:
  • True - AnyDAC is getting a field origin table and column additionally to the other column attributes. Setting this option to True may slow down a dataset opening.
  • False - AnyDAC uses the restricted information about the query columns. This is default value.
 
True 
ApplicationName 
Name of the application. If specified, this value is stored in the master.dbo.sysprocesses column program_name and is returned by sp_who and the Transact-SQL APP_NAME function. 
AllBooks 
ODBCAdvanced 
Allows to specify any other additional ODBC connection parameter value. 
MARS_Connection=no;Regional=yes 
MetaDefCatalog 
Default database name. Design time code will exclude catalog name from object name, if it is equal to MetaDefCatalog. 
Northwind 
MetaDefSchema 
Default schema name. Design time code will exclude schema name from object name, if it is equal to MetaDefSchema. 
dbo 
MetaCaseIns 
Controls metadata case-sensitivity:
  • True - case-insensitive metadata search will be used.
  • False - depends on the database collation. This is default value.
 
True 

 

Usage cases
  • Connect to local SQL Server instance, using SQL Server authentication:

 

DriverID=MSSQL
Server=127.0.0.1
Database=Northwind
User_Name=sa
MetaDefSchema=dbo
MetaDefCatalog=Northwind

 

  • Connect to SQL Express 2005, using Windows authentication:

 

DriverID=MSSQL
Server=DA\SQLEXPRESS
Database=Northwind
OSAuthent=Yes
MARS=no

 

  • Connect to SQL Azure. Note the "@<server>" suffix in User_Name and "tcp:" prefix in Server parameters:

 

DriverID=MSSQL
Server=tcp:nasdfert6.database.windows.net
Database=Northwind
User_Name=addemo@nasdfert6
Password=asd123zxc
Encrypt=Yes
MetaDefSchema=dbo
MetaDefCatalog=Northwind

 

  • Connect to LocalDB:

 

DriverID=MSSQL
Server=(localdb)\\v11.0
Database=master
OSAuthent=Yes

 

  • Connect to LocalDB and attach database file:

 

Server=(localdb)\\v11.0
DriverID=MSSQL
ODBCAdvanced=AttachDbFileName=C:\\Users\\Alex\\ADDemo.mdf
What do you think about this topic? Send feedback!