MongoDB.SetDatabase
-------------------

Sets the URI's database, after the URI has been parsed.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [MongoDB](component_MongoDB.md) | [13.1](newinversion131.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "MongoDB.SetDatabase"; MongoDBRef; DatabaseName ) 

**MBS**( **"MongoDB.SetDatabase";** /\* Sets the URI's database, after the URI has been parsed. \*/  
**$MongoDBRef**; /\* The reference number for the mongo connection.e.g. $MongoDB \*/   
**$DatabaseName**) /\* The new database name.e.g. "test" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| MongoDBRef | The reference number for the mongo connection. | $MongoDB |
| DatabaseName | The new database name. | "test" |

### Result

Returns OK or error.

### Description

Sets the URI's database, after the URI has been parsed.  
The driver authenticates to this database if the connection string includes authentication credentials. This database is used when you use [MongoDB.OpenDefaultDatabase](MongoDBOpenDefaultDatabase.md) function.  
### See also

- [MongoDB.CloseDatabase](MongoDBCloseDatabase.md)
- [MongoDB.FindDatabases](MongoDBFindDatabases.md)
- [MongoDB.OpenDatabase](MongoDBOpenDatabase.md)
- [MongoDB.OpenDefaultDatabase](MongoDBOpenDefaultDatabase.md)
- [MongoDB.WatchDatabase](MongoDBWatchDatabase.md)

### Release notes

- **Version 13.1**
    - Added [MongoDB.GetOptions](https://www.mbsplugins.eu/MongoDBGetOptions.shtml), [MongoDB.GetTLS](https://www.mbsplugins.eu/MongoDBGetTLS.shtml) and [MongoDB.SetDatabase](https://www.mbsplugins.eu/MongoDBSetDatabase.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin, version 13.1pr1](https://www.mbsplugins.de/archive/2023-02-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 22nd January 2023 , last changed 22nd January 2023

  
[MongoDB.SetCompressors](MongoDBSetCompressors.md) - [MongoDB.SetPassword](MongoDBSetPassword.md)

[HTML Version](MongoDBSetDatabase.shtml)