views:

164

answers:

1

Hello all,

I have mananed to use the odbc_connect like the following for access 2007 and 2003 and I can get data. But when I try to get the column names the following function will not work for access 2007 but will for acccess 2003 - why?

if($type[1]=='mdb'){

    $connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdbFilename", $username, $password);

}else{

    $connection = odbc_connect("Driver={Microsoft Access Driver (*.accdb)};Dbq=$mdbFilename", $username, $password);
}

function get_columns($activity_file){

    global $connection;

    global $typee;

    $coulmn_array = array();

    $result = odbc_columns($connection, $typee, "", $activity_file, "%");

    while (odbc_fetch_row($result)) {

        $coulmn_array[] = odbc_result($result, "COLUMN_NAME");

    }

    echo '<br>Exporting table '.$activity_file;

    return $coulmn_array;

}

I mean I can get the data and everything, it just seems this function just won't work!

Please help!

Update

I had a google around and found this thread.

I can confirm what this person is saying. Supplying a table_name means this won't work. But if you don't it will. This isn't acceptable as what columns are being returned and for what table? I need to know this!!

+1  A: 

This is a long shot, but there was a problem with the ODBC function SQLDescribeCol and SQLColAttributes related to Access 2007. Those functions would likely be used by odbc_columns. It is described in this KB article.

Mark Wilkins
I hope this isn't what is effecting me! I had a look at my office 2007 install and it shows this version number: 12.0.6425.1000.But the version for the patch looks like its: 12.0.6300.5000 - meaning I have hopefully have surpassed this version and therefore have a fix for it.
Abs
@Abs: That probably is not it then. Just as a sanity check, you might look at the version of aceodbc.dll to make sure it matches, but it sounds like you have the correct versions.
Mark Wilkins
Thank you for letting me know about that though. Something to be aware when I distribute these scripts.
Abs