Hi all,
I have a .db file. I want to connect that .db file to UiPath to get data from it by executing SQL statements. How can I do this?
Thanks,
Harmeet
Hi all,
I have a .db file. I want to connect that .db file to UiPath to get data from it by executing SQL statements. How can I do this?
Thanks,
Harmeet
Thanks for sharing. How can I create DSN for my .db file to use it in the connection activity in UIPath?
Working Solution tested in UiPath Studio 24.10.5 with System.Data.SQLite.1.0.119 from https://api.nuget.org/v3/index.json
for a Windows project compatibility
Install the System.Data.SQLite.1.0.119 dependency in your project in Manage Packages ribbon
Copy the “C:\Users\robot_username.nuget\packages\stub.system.data.sqlite.core.netstandard\1.0.119\runtimes\win-x64\native\SQLite.Interop.dll” file to Studio/Robot installation folder
Add an Invoke Code activity for CSharp language
try
{
string connectionString = "Data Source=C:\\Users\\robot_username\\Documents\\UiPath\\ExtractPDT_Test\\REPLACE_WITH_DATABASE_FILE_NAME.db;Version=3;";
using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(connectionString))
{
conn.Open();
string sql = "SELECT * FROM REPLACE_WITH_TABLE_NAME";
using (System.Data.SQLite.SQLiteCommand command = new System.Data.SQLite.SQLiteCommand(sql, conn))
{
using (System.Data.SQLite.SQLiteDataReader reader = command.ExecuteReader())
{
DataTable dt = new System.Data.DataTable();
dt.Load(reader);
query_output = dt;
}
}
}
}
catch (Exception e)
{
string error = e.Message;
error_output = error;
}
Results after execution: