How to MySql Database using UiPath

Currently, I am Facing a Glitch to connect the Mysql database.

Here is my scenario,

1.UiPath Studio - Installed in my machine
2. Mysql database - Installed in another Virtual machine.

Question:
How to connect the Mysql Database and retrieve the table values using UiPath.

Thanks,
Jayakumar.R.

use connect activity and connect to the database … then use execute query and get your data

Hi @Jay1737,

You’ll need a MySQL Connector to be installed for this on the machine where your Job/Process/robot will run. Install the exe and then you can use “Connect” activity with provider as “MySql.Data.MySqlClient” and Connection string like

“Server=YourHostName;Port=PortNumber;Database=DatabaseName;Uid=userName;Pwd=Password;”

You can download the MySQL connector online for window: https://dev.mysql.com/downloads/connector/odbc/

Note that you’ll have to install this connector on all machines which will be making DB transactions. Additionally, kindly check if your target machine is able to reach the server where your MySQL DB is located.

Thank you Jagadish,

I have installed MySQL Connector/ODBC 8.0 successfully,


But In UiPath studio not yet getting or reflecting this driver. Please refer the below screen shot.
image
And how to enable Mysql Connector in UiPath.

Hi,

Apologies for missing out on this but could you install this:
https://dev.mysql.com/downloads/connector/net/

You can follow the rest of the steps after this.

Thank you very much, It’s working fine now.

And how to pass variables in mysql query(Execute Query) in UiPath.
I’ll tried this way . but it’s not working.

Error as "Execute Query: String[1]: the Size property has an invalid size of 0."


Thanks,
Jayakumar.R

Hi Jay,

If you’re using Execute query then that means you’re just trying to retrieve information from the database and store in a Datatable in Uipath.

If you’re trying to use update/insert queries then use “Execute non Query” and parameter directions need to be “IN”. Parameter names should be starting with “@” and must be equal to the column name from the database

Example : Query should look like “insert into dbo.TableName values (@Name, @Age)” and the parameter names section in your activity should have @Name followed by the direction and the datatype corresponding to the datatype of the DB column (eg. String should be used when it’s Varchar).

Let me know if this helps.

While I am trying to use an “Execute query” also getting an same error.
"Error : Execute Non Query: String[1]: the Size property has an invalid size of 0. "

Thanks,
Jayakumar.R

And while passing an variable values through query with Execute query is working.But Passing with parameter it won’t work. Please do the needful.

1. With variable query:

“INSERT INTO tablename (statement_date) VALUES (@statement_date)”

image

2.With passing Parameter

“INSERT INTO tablename ( statement_date) VALUES (”&"’"& Arg_statement_date &"’"&")"

image