Ubuntu – How to connect Ubuntu to a MS SQL server 2005

databasedotnetsqlwine

I am using Ubuntu 13.04 and I installed Wine 1.6. I am running a dotnet application through Wine, but I am getting the following error message:

An error occurred while establishing connection to the server. When connecting to SQL server 2005,this failure may be caused by the fact that under the default setting SQL server does not allow remote connections.

The dotnet framework 2.0 installed in Ubuntu client. But the same dotnet applications runs in Windows client machines (Windows 7/Windows XP).

Do I need to establish connections manually to that server? Or do I need to install any application for this to establish connections?

Best Answer

You don't have to use Wine for this purpose. Connecting Ubuntu to a Microsoft SQL server is not really possible as the Microsoft MDAC doesn't install on Ubuntu, even in Wine. Here is a good guide that I found in this sense: http://www.omegaprojex.com/index.php/2010/10/15/connecting-ubuntu-to-sql-server-2005-natively/

Here is a quick overview:

  1. Install all the packages needed to get connected to SQL server:

    sudo apt-get install iodbc libiodbc2 libct3 tdsodbc unixodbc
    
  2. Edit /etc/odbcinst.ini file and add the following:

    [FreeTDS]
    Description = FreeTDS Driver
    Driver = /usr/lib/odbc/libtdsodbc.so
    Setup = /usr/lib/odbc/libtdsS.so
    FileUsage = 1
    CPTimeout = 5
    CPReuse = 5
    
  3. Edit /etc/odbc.ini file and add the following:

    [ODBC Data Sources]
    MyServerDSN = FreeTDS Connection Server
    [MyServerDSN]
    Driver = FreeTDS
    Description = FreeTDS Connection Server
    Servername = MyServer
    Database = MyDatabase
    
  4. Edit /etc/odbc.ini file and add the following at the end of file:

    [MyServer]
    host = x.x.x.x
    port = 1433
    tds version = 8.5
    
  5. Connect to SQL server:

    isql -v MyServerDSN MyUserName MyPass