Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Why do I get an "Incompatible types" error when running an SQL command on an Excel Spreadsheet?

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.

Example:

[-] 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)


 

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:21
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.