php freetds and iodbc

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • grezios
    New Member
    • Apr 2007
    • 3

    php freetds and iodbc

    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
    MSSQL = MAVE

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


    [iODBC]
    Driver = some dirs/libtdsodbc.so
    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

    [Default]
    Driver = some dirs /libtdsodbc.so


    i have performed the test that is in the iodbc openlink website (http://www.iodbc.org/index.php?page=...TO#php23039346)

    and the result is the following

    ---------------------------------------------
    Connecting...
    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


    [000000.184459]
    php 00000000 EXIT SQLConnect with return code -1 (SQL_ERROR)
    SQLHDBC 0xa255090
    SQLCHAR * 0xa25940c
    SQLSMALLINT -3 (SQL_NTS)
    SQLCHAR * 0xa2596ec
    SQLSMALLINT -3 (SQL_NTS)
    SQLCHAR * 0x575258
    SQLSMALLINT -3 (SQL_NTS)

    [000000.184627]
    php 00000000 ENTER SQLError
    SQLHENV 0xa259988
    SQLHDBC 0xa255090
    SQLHSTMT 0x0 (SQL_NULL_HANDL E)
    SQLCHAR * 0xbfd2364e
    SQLINTEGER * 0xbfd23654
    SQLCHAR * 0xbfd2344e
    SQLINTEGER 511
    SQLSMALLINT * 0xbfd2365a

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

    [000000.184914]
    php 00000000 ENTER SQLFreeConnect
    SQLHDBC 0xa255090

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

    i dont understand a thing. PLEASE HELP.
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Can you connect regularly? From the same machine? How about from another machine using the Windows Client Tools?

    Comment

    • grezios
      New Member
      • Apr 2007
      • 3

      #3
      Originally posted by Motoma
      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

      Comment

      Working...