The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ODBC to remote database

Discussion in 'Database Discussions' started by wineo, Apr 6, 2011.

  1. wineo

    wineo Active Member

    Joined:
    Aug 30, 2003
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Perth, Australia
    Hi,

    I am trying to use ODBC (unixODBC and freeTDS installed) from our CentOS server to retrieve data from a remote windows pc, specifically from a medical database that has .dbf files holding the data. I presume that this is a dbase type database.

    Is this possible? Does anyone have example config files for TDS and ODBC?

    My TDS config file:
    PHP:
    [TDS]
    host remote.domain.com
    port 
    81
    tds version 
    7.0
    My odbc.ini file:
    PHP:
    [LDdbase]
    Description blah blah
    Driver 
    LDdbase
    Servername 
    remote.domain.com
    Port 
    81
    Database 
    freddb
    My odbcinst.ini file:
    PHP:
    [TDS]
    Description     blah blah
    Driver          
    = /usr/lib/libmyodbc.so
    Setup           
    = /usr/lib/libodbcmyS.so
    FileUsage       
    1
    My php file where I am trying to connect:
    PHP:

    putenv
    ("ODBCSYSINI=/etc/odbcinst.ini");
    putenv("ODBCINI=/etc/odbc.ini");

    $ld odbc_connect('LDdbase''''') or die ("couldn't connect");

    if (
    $ld)
    {
        echo 
    "connected";
    }
    else echo 
    "ODBC not connected";

    odbc_close($ld);
    I have been trying the domain name (setup for the remote pc) and the IP address, but I have a feeling that it is failing to connect to the pc.

    I keep getting this error message on the web page where I am trying to connect:
    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 /home/acc/public_html/import.php on line 5

    Thanks.
     
    #1 wineo, Apr 6, 2011
    Last edited: Apr 6, 2011
  2. wineo

    wineo Active Member

    Joined:
    Aug 30, 2003
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Perth, Australia
    Still not there yet, but I think I am closer.

    I used system('odbcinst -j') to debug the config file being used. I reset ODBCSYSINI to:
    PHP:
    putenv("ODBCSYSINI=/etc");
    This showed up a new error. I was using the 32bit and not the 64bit libs. Now after pointing to the right version of the libs I am now getting this error: SQL error: [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed, SQL state IM004 in SQLConnect in...

    My first guess is that I am using the wrong connection libs. Can anyone confirm?
     
  3. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
  4. wineo

    wineo Active Member

    Joined:
    Aug 30, 2003
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Perth, Australia
    Thanks cPanelTristan,

    I think I have the server trying to connect to the pc, but the ODBC (FoxPro) driver on the pc doesn't seem to be responding to the connection. I am not sure how to configure the pc to listen on a certain port and connect when the server tries to. I think that this is half the problem and the other issue may be that the ODBC on the pc is set to free table directory and there is no username and password for the tables in this folder. Again not sure how to handle this...

    Sort of stuck now... not sure what to do. May resort to enabling the dbase extension/functions on the server?
     
Loading...

Share This Page