2

I am getting error

odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect for Linux server

while executing following command to connect with sybase from PHP.

$db = ADONewConnection('odbc');

$DSN = 'UID=username;PWD=password;EngineName=dbServiceName;AutoStop=No;Integrated=No;Debug=No;DisableMultiRowFetch=No;CommLinks=SharedMemory,TCPIP{};Compress=No;Driver={Adaptive Server Anywhere 9.0}';


$db->Connect($DSN );

I have installed ODBC drivers with FreeTDS to connect Sybase database with PHP code with following commands

  • sudo apt-get install unixodbc
  • sudo apt-get install tdsodbc
  • sudo apt-get install freetds-bin tdsodbc

/etc/odbc.ini file

  • Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
  • Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
  • Server = server_name
  • Port = port_number
  • Database = dbname
  • Username = dbusername
  • Password = dbpassword

freetds.conf file

[sybase]
    host=
    port=
    Tds version=

1 Answer 1

0

If you're using FreeTDS, you need to specify the driver from odbcinst.ini, which is normally FreeTDS. Try:

$DSN = 'UID=username;PWD=password;EngineName=dbServiceName;AutoStop=No;Integrated=No;Debug=No;DisableMultiRowFetch=No;CommLinks=SharedMemory,TCPIP{};Compress=No;Driver={FreeTDS}';
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot for suggestion. I have tried to connect database server using terminal and it is working fine but I am getting same error in php connection? I have tried in terminal "tsql -S SYBASE -U <username> -P <password>"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.