SQLClose (function)




Closes the connection to the specified data source.


The unique connection ID (connectionID) is a Long value representing a valid connection as returned by SQLOpen. After SQLClose is called, any subsequent calls made with the connectionID will generate runtime errors.

The SQLClose function returns 0 if successful; otherwise, it returns the passed connection ID and generates a trappable runtime error. Additional error information can then be retrieved using the SQLError function.


The Basic Control Engine automatically closes all open SQL connections when either the script or the application terminates. You should use the SQLClose function rather than relying on the application to automatically close connections in order to ensure that your connections are closed at the proper time.


This example disconnects the data source sample.

Sub Main()
  Dim s As String
  Dim qry As Long
  id& = SQLOpen("dsn=SAMPLE",s$,3)
  qry = LExecQuery(id&,"Select * From c:\sample.dbf")
  MsgBox "There are " & qry & " records in the result set."
  id& = SQLClose(id&)
End Sub

See Also

SQLOpen (function).

More information