Why do I get an "Incompatible types" error when running an SQL command on an Excel Spreadsheet?
This error can occur when closing a SQL Connection from an Excel Spread Sheet. The DB_FinishSQL () method needs to close the SQL handle. The error will occur when you try to close the SQL String instead of the file handle. To resolve this issue make sure you are closing the SQL handle.
[-] testcase Database_example () [ ] //To tell DBTester what DB to connect to [ ] STRING sConnectString = "DSN=Test;DBQ=C:\example1.xls" [ ] [ ] //Connect to database and keep a reference to it [ ] HANDLE hDB = DB_Connect (sConnectString) [ ] [ ] //SQL Command to be carried out on DB [ ] STRING sSQL = "SELECT * FROM `Sheet1$` `Sheet1$`" [ ] [ ] //Execute the SQL Statement and keep a reference to the resulting table [ ] HANDLE hSQL = DB_ExecuteSQL (hDB, sSQL) [ ] [ ] //Variable to hold any data retrieved from the database [ ] LIST OF ANYTYPE laData [ ] [ ] //Query result table and copy data into variable [-] while (DB_FetchNext(hSQL, laData)) [ ] //Print one record at a time to a results file [ ] Print (laData) [ ] [ ] //Clean Up and Disconnect [ ] DB_FinishSQL (sSQL) // incorrect [ ] DB_FinishSQL (hSQL) // correct [ ] DB_Disconnect (hDB)