SQL.FreeConnection
------------------

Call this method if you are done with a connection.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SQL](component_SQL.md) | [2.6](newinversion26.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SQL.FreeConnection"; Connection ) 

**MBS**( **"SQL.FreeConnection";** /\* Call this method if you are done with a connection. \*/  
**$Connection**) /\* The command reference number gained with [SQL.NewConnection](SQLNewConnection.md). \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Connection | The command reference number gained with [SQL.NewConnection](SQLNewConnection.md). | $Connection |

### Result

Returns "OK" or error message.

### Description

Call this method if you are done with a connection.  
This closes the connection and frees all memory allocated for it.  
Internally calls [SQL.Disconnect](SQLDisconnect.md) if needed.  
### Examples

Free connection object:

 MBS ( "SQL.FreeConnection"; $Connection )  
### See also

- [SQL.ClientVersion](SQLClientVersion.md)
- [SQL.Connect](SQLConnect.md)
- [SQL.Execute](SQLExecute.md)
- [SQL.FreeAllConnections](SQLFreeAllConnections.md)
- [SQL.GetFieldAsContainer](SQLGetFieldAsContainer.md)
- [SQL.GetFieldAsText](SQLGetFieldAsText.md)
- [SQL.InsertOrUpdateRecords](SQLInsertOrUpdateRecords.md)
- [SQL.InternalSQLiteLibrary.Dump](SQLInternalSQLiteLibraryDump.md)
- [SQL.NewCommand](SQLNewCommand.md)
- [SQL.ResetConnection](SQLResetConnection.md)

### Release notes

- **Version 9.5**
    - Fixed a bug in [SQL.FreeConnection](http://www.mbsplugins.eu/SQLFreeConnection.shtml) freeing wrong command objects.
- **Version 9.3**
    - Fixed potential crash with [SQL.FreeCommand](http://www.mbsplugins.eu/SQLFreeCommand.shtml) and [SQL.FreeConnection](http://www.mbsplugins.eu/SQLFreeConnection.shtml) in server scripts.

### Example Databases

- [SQL to other databases/DuckDB Query](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/DuckDB%20Query.shtml#1ScriptAnchor_)
- [SQL to other databases/Microsoft SQL Execute](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/Microsoft%20SQL%20Execute.shtml#1ScriptAnchor_)
- [SQL to other databases/Microsoft SQL Server Connect](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/Microsoft%20SQL%20Server%20Connect.shtml#1ScriptAnchor_)
- [SQL to other databases/Microsoft SQL Server Query](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/Microsoft%20SQL%20Server%20Query.shtml#1ScriptAnchor_)
- [SQL to other databases/MySQL example](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/MySQL%20example.shtml#1ScriptAnchor_)
- [SQL to other databases/MySQL Query](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/MySQL%20Query.shtml#1ScriptAnchor_)
- [SQL to other databases/ODBC to FIleMaker/ODBC Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/ODBC%20to%20FIleMaker/ODBC%20Test.shtml#1ScriptAnchor_)
- [SQL to other databases/PostgreSQL Query](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/PostgreSQL%20Query.shtml#1ScriptAnchor_)
- [SQL to other databases/SQLite blob](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/SQLite%20blob.shtml#1ScriptAnchor_)
- [Third Party/FileMaker Snippet Storage](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Third%20Party/FileMaker%20Snippet%20Storage.shtml#35CustomFunctionAnchor_)

### Blog Entries

- [Connect to DuckDB in FileMaker](https://www.mbsplugins.de/archive/2025-04-10/Connect_to_DuckDB_in_FileMaker/monkeybreadsoftware_blog_filemaker)
- [Connect to Postgres in FileMaker](https://www.mbsplugins.de/archive/2025-04-09/Connect_to_Postgres_in_FileMak/monkeybreadsoftware_blog_filemaker)
- [Moving data from ODBC to FileMaker via script](https://www.mbsplugins.de/archive/2023-02-12/Moving_data_from_ODBC_to_FileM/monkeybreadsoftware_blog_filemaker)
- [Transactions with SQL functions](https://www.mbsplugins.de/archive/2022-04-28/Transactions_with_SQL_function/monkeybreadsoftware_blog_filemaker)
- [Using TLS when connecting to MySQL server](https://www.mbsplugins.de/archive/2020-08-20/Using_TLS_when_connecting_to_M/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.5pr1](https://www.mbsplugins.de/archive/2019-10-02/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.3pr7](https://www.mbsplugins.de/archive/2019-07-21/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [Tip of the day: Connect to MySQL and run a query](https://www.mbsplugins.de/archive/2017-02-07/Tip_of_the_day_Connect_to_MySQ/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 2/2022, Seite 29](https://filemaker-magazin.de/neuigkeit/4174-Appetithappen-FMM_202202)
- [Ausgabe 4/2016, Seite 28](https://filemaker-magazin.de/neuigkeit/3876-Appetithappen-FMM_201604)
- [Ausgabe 3/2016, Seite 29 bis 30](https://filemaker-magazin.de/neuigkeit/3883-Appetithappen-FMM_201603)
- [Ausgabe 1/2016, Seite 30](https://filemaker-magazin.de/neuigkeit/3870-Appetithappen-FMM_201601)
- [Ausgabe 1/2016, Seite 28](https://filemaker-magazin.de/neuigkeit/3870-Appetithappen-FMM_201601)
- [Ausgabe 4/2015, Seite 16](https://filemaker-magazin.de/neuigkeit/3822-Appetithappen-FMM_201504)

This function is free to use.

Created 18th August 2014 , last changed 5th October 2020

  
[SQL.FreeCommand](SQLFreeCommand.md) - [SQL.GetAutoCommit](SQLGetAutoCommit.md)

[HTML Version](SQLFreeConnection.shtml)