# Best practices

> When using stored procedures in Oracle, ensure that the REF CURSOR is correctly bound with the `Oracle.ManagedDataAccess.Types.OracleRefCursor` variable.

## Using a store procedure with OracleRefCursor

When using stored procedures in Oracle, ensure that the REF CURSOR is correctly bound with the `Oracle.ManagedDataAccess.Types.OracleRefCursor` variable.

To do so, you need to make sure the number of parameters and their type match the ones setup in the **Parameters** property of the **Run Query** activity.

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/developer-docs-image-457401-601bfd4e-4954adfc.webp)

You can get the content of the cursor using the [Invoke Code](https://docs.uipath.com/activities/other/latest/workflow/invoke-code) activity or you can pass it to another database query as an input parameter. Here is a sample invoke code to convert it to a data table:

```
Oracle.ManagedDataAccess.Client.OracleDataReader reader2 = myRefCursor.GetDataReader();
                dt = new DataTable();
                dt.Load(reader2);
```

You should dispose the cursor when you are done with it. You can do it either with Invoke Code activity (`myRefCursor.Dispose`), with Invoke Method activity from the System activity package or via an SQL command that you run.

## Connection strings for different database systems

This guide provides sample connection strings for the [Connect to Database](https://docs.uipath.com/activities/other/latest/developer/database-connect) activity, enabling you to connect to various databases using native and ODBC drivers. It includes examples for Microsoft SQL Server and popular ODBC drivers such as MySQL, Oracle, and PostgreSQL. Follow best practices to ensure secure and efficient database connectivity.

### Microsoft SQL Server

Common connection string formats for Microsoft SQL Server when using the Microsoft.Data.SqlClient

1. Using SQL Server authentication:

   `Data Source=SERVER_NAME;Initial Catalog=DATABASE_NAME;User ID=USERNAME;Password=PASSWORD;`

2. With a specific port:

   `Data Source=SERVER_NAME,PORT_NUMBER;Initial Catalog=DATABASE_NAME;User ID=USERNAME;Password=PASSWORD;`

3. Using the ODBC driver

   `Driver={ODBC Driver 18 for SQL Server};Server=SERVER_NAME;Database=DATABASE_NAME;Uid=USERNAME;Pwd=PASSWORD;Encrypt=yes;TrustServerCertificate=no;`

You can learn more about it via the official Microsoft documentation page [here](https://learn.microsoft.com/en-us/sql/connect/ado-net/connection-string-syntax?view=sql-server-ver17).

### Excel file

`Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=C:\full\path\to\the\sampleFile.xlsx;`

### Oracle Managed Data Access

`Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XEPDB1)));User II=system;Password=your_password;`

You can learn more about it via the official Microsoft documentation page [here](https://docs.oracle.com/en/database/oracle/oracle-database/21/odpnt/InstallManagedConfig.html).

### MySQL ODBC 8.3 Unicode Driver

`Driver={MySQL ODBC 8.3 Unicode Driver};Server=SERVER_NAME;Database=DATABASE_NAME;User=USERNAME;Password=PASSWORD;Option=3;`

You can learn more about it via the official MySQL documentation page [here](https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-configuration-connection-parameters.html).

### MySQL ODBC 8.3 ANSI Driver

`Driver={MySQL ODBC 8.3 ANSI Driver};Server=SERVER_NAME;Database=DATABASE_NAME;User=USERNAME;Password=PASSWORD;Option=3;`
