Rewritten most code in odbc. Also other functions related to SQL