# Change Connection String dynamically through a report parameter

## Environment

<table>
	<tr>
		<td>Product</td>
		<td>Progress® Telerik® Reporting </td>
	</tr>
</table>

## Description

Sometimes it is necessary to change dynamically the connection string of a report and/or data item.

## Solution

The requirement can be achieved without writing additional code, **_directly in the report definition_** using dedicated report parameters. Here are the steps:

1. In the report definition [introduce a new Report Parameter](https://www.telerik.com/products/reporting/documentation/designing-reports/connecting-to-data/report-parameters/how-to-add-report-parameters) (for example *ConnectionStringParameter*) - the connection string will be passed to the Report via this parameter.
2. In the Report or another [Data Item](https://www.telerik.com/products/reporting/documentation/designing-reports/connecting-to-data/data-items/overview) (Table, List, etc.) where the connection string is supposed to be changed dynamically, introduce a new [Binding](https://www.telerik.com/products/reporting/documentation/designing-reports/connecting-to-data/expressions/using-expressions/bindings) as shown below:

   ```TEXT
   Property path                   |   Expression

   DataSource.ConnectionString     |   = Parameters.ConnectionStringParameter.Value
   ```

![Changed dynamically the connection string by using Binding](https://www.telerik.com/products/reporting/documentation/assets/09d8fd11678a0c4e6e1ba46fd77df1fd/changeconnectionstringdynamicallywithbinding.png)

## Notes

The `DataSource.ConnectionString` property is not listed in the dropdown and must be typed manually.

The proposed approach *cannot* be used to modify the Connection String of Report Parameter -> AvailableValues -> DataSource as report parameters do not expose `Bindings`.

The same approach can be used to modify the `SelectCommand` Property of the SqlDataSource. The `DataSource.SelectCommand` should be set in the above code snippet in this case.

## See Also

* [Changing the connection string dynamically according to runtime data](https://www.telerik.com/support/kb/reporting/details/changing-the-connection-string-dynamically-according-to-runtime-data)
