Description
In Microsoft Excel for Windows 95, do not use SQLClose and the other ODBC functions in the XLODBC.XLA add-in; use the objects, methods, and properties in the Data Access Objects (DAO) library instead.
SQLClose closes a connection to an external data source.
This function is contained in the XLODBC.XLA add-in (ODBC Add-In on the Macintosh). Before you use the function, you must establish a reference to the add-in using the References command (Tools menu).
Syntax
SQLClose(connectionNum)
connectionNum
Required. The unique connection ID of the data source from which you want to disconnect.
Return Value
If the connection is successfully closed, this function returns 0 (zero) and the connection ID is no longer valid.
If connectionNum is not valid, this function returns Error 2015.
If SQLClose is unable to disconnect from the data source, it returns Error 2042.
See Also
SQLBind Function, SQLError Function, SQLExecQuery Function, SQLGetSchema Function, SQLOpen Function, SQLRequest Function, SQLRetrieve Function, SQLRetrieveToFile Function.
Example
This example runs a query on the NWind sample database. The result of the query, displayed on Sheet1, is a list of all products that are currently on order.
If Application.OperatingSystem Like "*Win*" Then databaseName = "NWind" Else 'Macintosh databaseName = "NorthWind" End If queryString = "SELECT * FROM product.dbf WHERE (product.ON_ORDER<>0)" chan = SQLOpen("DSN=" & databaseName) SQLExecQuery chan, queryString Set output = Worksheets("Sheet1").Range("A1") SQLRetrieve chan, output, , , True SQLClose chan