By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,723 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,723 IT Pros & Developers. It's quick & easy.

php freetds and iodbc

P: 3
Hi everybody and first of all thank you very much for your help,
i am on a linux fedora core 5 server and i want to odbc connect to a windows 2003 server with MSSQL Server database.
the iODBC is the name i used for defining the dsn i have created in the odbc.ini file which looks like this

[ODBC Data Sources]
iODBC = MS SQL Server

Driver = /usr/local/lib/
Description = MSSQL
Trace = No
Server = xxx.xx.xx.xx
Database = databaseName
Port = xxxx //the default is 1433
Password = my password

Driver = some dirs/
Description = Sample iODBC Server
Host = xxx.xx.xx.xx
Server = xxx.xx.xx.xx
#Address = xxx.xx.xx.xx
Port = xxxx
#TraceFile = stdout
TraceFile = o.trc
Trace = 1 ; set to 1 to enable tracing
#UID = i use here the username of the db login
#Password = password
#PWD = password
Database = the database name
ServerType = MS SQL Server
Debug = 1
DebugFile = odbcdebug.log

Driver = some dirs /

i have performed the test that is in the iodbc openlink website (

and the result is the following

Warning: odbc_connect() [function.odbc-connect]: SQL error: [FreeTDS][SQL Server]Read from SQL server failed., SQL state 08S01 in SQLConnect in ..... my website /odb.php on line 64

Uh-oh! Failure to connect to DSN [iODBC]:

for the error 08S01 microsoft says

The communication link between the driver and the data source to which the driver was attempting to connect failed before the function completed processing.

i say ?????????

I use iODBC driver manager and the actual driver is the FreeTDS driver.
The test tsql on command line is connecting without problems and i can also perform queries etc.... The problem comes when i try to use the function odbc_connect(). it is returning the error above. When i change the name of the DSN to something else i get the error

[iODBC][Driver Manager]Data source name not found and no default driver specified. Driver could not be loaded, SQL state IM002 in SQLConnect in .....

I used the trace file for iODBC and the result is the following:

** iODBC Trace file
** Trace started on Tue Apr 17 14:21:39 2007
** Driver Manager: 03.52.0507.0105

php 00000000 EXIT SQLConnect with return code -1 (SQL_ERROR)
SQLHDBC 0xa255090
SQLCHAR * 0xa25940c
SQLCHAR * 0xa2596ec
SQLCHAR * 0x575258

php 00000000 ENTER SQLError
SQLHENV 0xa259988
SQLHDBC 0xa255090
SQLCHAR * 0xbfd2364e
SQLINTEGER * 0xbfd23654
SQLCHAR * 0xbfd2344e
SQLSMALLINT * 0xbfd2365a

php 00000000 EXIT SQLError with return code 0 (SQL_SUCCESS)
SQLHENV 0xa259988
SQLHDBC 0xa255090
SQLCHAR * 0xbfd2364e
| 08S01 |
SQLINTEGER * 0xbfd23654 (20004)
SQLCHAR * 0xbfd2344e
| [FreeTDS][SQL Server]Read from SQL serve |
| r failed. |
SQLSMALLINT * 0xbfd2365a (49)

php 00000000 ENTER SQLFreeConnect
SQLHDBC 0xa255090

php 00000000 EXIT SQLFreeConnect with return code 0 (SQL_SUCCESS)
SQLHDBC 0xa255090

i dont understand a thing. PLEASE HELP.
Apr 23 '07 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 3,235
Can you connect regularly? From the same machine? How about from another machine using the Windows Client Tools?
Apr 23 '07 #2

P: 3
Can you connect regularly? From the same machine? How about from another machine using the Windows Client Tools?
i have tested the connection by adding my code on a windows machine and it worked great, but the settings of the php where diferent and the driver i used on that machine where the native odbc driver and the MSSQL Server driver which are not available on unix machines. Now i want to connect with the FreeTDS drivers supported by the iODBC Driver manager. This is totaly diferent now and the previews connection i made (on windows machine) tells me only that the connection with the remote machine can be established (port is open, password and username are correct ip address is correct and Generaly the DSN i use is correct except from the driver). Thank you very much for the reply and i hope this information helps
Apr 24 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.