Results 1 to 6 of 6

Thread: ODBC Connection to MSSQL Server

  1. #1
    Join Date
    Aug 2008
    Beans
    2
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Unhappy ODBC Connection to MSSQL Server

    Hi i have tried without success to connect to an mssql server via odbc/php5 i can't configure correctly the connection driver.

    Here the error:
    Code:
    Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/default/dbmacchine/test.php on line 3
    And here my config:

    /etc/odbc.ini & /etc/odbcinst.ini
    Code:
    [TECNO60]
    Driver        = FreeTDS
    Description     = Conexion a Sql  con FreeTDS / ODBC
    Trace         = No
    Servername    = 172.16.1.3
    Database    = TECNO60
    
    [default]
    Driver        = FreeTDS
    Description     = Conexion a Sql  con FreeTDS / ODBC
    Trace         = No
    Servername    = 172.16.1.3
    Database    = TECNO60
    Last edited by fabio.casolari; March 17th, 2009 at 03:35 PM.

  2. #2
    Join Date
    Feb 2009
    Beans
    29

    Re: ODBC Connection to MSSQL Server

    Trying to do a similar thing (just connect in general).

    Can't find any helpful info and by helpful I mean anything that works.

  3. #3
    Join Date
    Aug 2008
    Beans
    2
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: ODBC Connection to MSSQL Server

    FOUND A SOLUTION:

    on Ubuntu Server I needed to install some packages

    Code:
    sudo aptitude install unixodbc unixodbc-dev freetds-dev sqsh tdsodbc
    With FreeTDS installed I could configure it like this:

    Code:
    /etc $ cat freetds.conf
    [SERVER]
      host = 192.168.0.10
      port = 1433
      tds version = 7.0
    The important thing here is SERVER, which is the DSN that I’ll use when connecting to the database. The host, and port are self-explanatory, and it’s worth nothing that I had to use 7.0 specifically as the tds version.

    Testing FreeTDS is not too hard:

    Code:
    $ sqsh -S SERVER -U username -P password
    sqsh: Symbol `_XmStrings' has different size in shared object, consider re-linking
    sqsh-2.1 Copyright (C) 1995-2001 Scott C. Gray
    This is free software with ABSOLUTELY NO WARRANTY
    For more information type '\warranty'
    1> use test
    2> go
    1> select top 1 firstname, lastname from tblClients
    2> go
    
    [record returned]
    
    (1 row affected)
    1> quit
    Next up it’s necessary to configure ODBC:

    Code:
    /etc$ cat odbcinst.ini
    [FreeTDS]
    Description     = TDS driver (Sybase/MS SQL)
    Driver          = /usr/lib/odbc/libtdsodbc.so
    Setup           = /usr/lib/odbc/libtdsS.so
    CPTimeout       =
    CPReuse         =
    FileUsage       = 1
    
    /etc$ cat odbc.ini
    [SERVER]
    Driver          = FreeTDS
    Description     = ODBC connection via FreeTDS
    Trace           = No
    Servername      = SERVER
    Database        = DATABASE
    I then tested the connection with isql:

    Code:
    $ isql -v SERVER username password
    +---------------------------------------+
    | Connected!                            |
    |                                       |
    | sql-statement                         |
    | help [tablename]                      |
    | quit                                  |
    |                                       |
    +---------------------------------------+
    SQL> use DATABASE
    [][unixODBC][FreeTDS][SQL Server]Changed database context to 'database'.
    [ISQL]INFO: SQLExecute returned SQL_SUCCESS_WITH_INFO
    SQLRowCount returns -1
    SQL> select top 1 firstname from tblClients;
    
    [record returned]
    
    SQLRowCount returns 1
    1 rows fetched
    SQL> quit
    OK, so we’ve got ODBC using FreeTDS to connect to a remote MSSQL server.

    Bye,
    Fabio Casolari
    http://www.ripartodazero.it

  4. #4
    Join Date
    Apr 2007
    Beans
    Hidden!

    Re: ODBC Connection to MSSQL Server

    Grazie Fabio... I was really going mad.

  5. #5
    Join Date
    Aug 2011
    Beans
    21

    Re: ODBC Connection to MSSQL Server

    me too facing the same problem and i tried that solution,
    but after installing

    [code]
    sudo aptitude install unixodbc unixodbc-dev freetds-dev sqsh tdsodbc
    when i tried
    [code]
    /etc $ cat freetds.conf
    /etc $
    their is no such file!!!


    what should i do??

  6. #6
    Join Date
    Apr 2008
    Beans
    4

    Re: ODBC Connection to MSSQL Server

    Quote Originally Posted by vineeth v s View Post
    me too facing the same problem and i tried that solution,
    but after installing

    [code]
    sudo aptitude install unixodbc unixodbc-dev freetds-dev sqsh tdsodbc
    when i tried
    [code]
    /etc $ cat freetds.conf
    /etc $
    their is no such file!!!


    what should i do??
    Try this
    Code:
    cat /etc/freetds/freetds.conf
    Remember this, when in doubt tab it out (basically frantically hit tab before finishing the file name, dir name, etc.)

    Also you'll want to use nano or vi for editing (gedit for the less extreme users), cat just displays the contents of files

    So
    Code:
    nano /etc/freetds/freetds.conf

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •