2025-06-19 21:58:02 +03:00
---
sidebar_position: 5
description: Generate connection string and other functions to work with MS SQL in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, MS SQL]
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Generate connection string
Forms a connection string from the passed data
2025-06-25 13:17:23 +03:00
`Function GenerateConnectionString(Val Address, Val Base = "", Val Login = "", Val Password = "", Val Port = "", Val WindowsAuth = False) Export`
2025-06-19 21:58:02 +03:00
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
2025-06-25 13:17:23 +03:00
| Address | --addr | String | ✔ | Database server address and instance |
2025-06-19 21:58:02 +03:00
| Base | --db | String | ✖ | Name of the database to connect |
| Login | --login | String | ✖ | mssql user login |
| Password | --pass | String | ✖ | mssql user password |
2025-06-25 13:17:23 +03:00
| Port | --port | Number | ✖ | Server port |
2025-06-19 21:58:02 +03:00
| WindowsAuth | --trust | Boolean | ✖ | Use Windows authentication. The login and password will be ignored |
Returns: String - MSSQL connection string
<br/>
:::tip
2025-06-20 22:31:25 +03:00
This function allows you to quickly assemble a basic connection string. In case you need more flexible configuration, you can also form (obtain) this connection string on your own (ADO format)
2025-06-19 21:58:02 +03:00
:::
<br/>
```bsl title="1C:Enterprise/OneScript code example"
2025-06-29 14:35:33 +03:00
Address = "127.0.0.1";
2025-06-25 13:17:23 +03:00
Login = "bayselonarrend";
2025-06-29 14:35:33 +03:00
Password = "12we...";
2025-06-25 13:17:23 +03:00
Base = "";
2025-06-19 21:58:02 +03:00
2025-06-25 13:17:23 +03:00
Result = OPI_MSSQL.GenerateConnectionString(Address, Base, Login, Password);
2025-06-19 21:58:02 +03:00
```
2025-07-01 19:40:39 +03:00
```json title="Result"
"Server=127.0.0.1;User Id=bayselonarrend;Password=***;"
```