How to to Add & write DB Connection Variable through Config variable

DB connection has been given in InItAllApplication, so i need add that connection Variable to Config file. Then I need to give that connection name into run query activity.

Getting below error, Please let me know how to resolve.

I tried this way.

In_Config(DBConnection) = DB_Connection 

image

image

Thanks in advance

@ManjunathReddy

So you want to get data from config file right?

In that case:
DB_Connection = In_Config(“DBConnection”).ToString

Hi @ManjunathReddy

Before passing to the DatabaseConnection can you put writeline activity and check if you are getting the desired value?

If not then you need to check the passing of the In_Config correctly?

Thanks,
Srini

Hi @ManjunathReddy

Pass in the below way in Assign activity:

DB_Connection = In_Config(DBConnection).toString

Hope it helps!!
Regards

You can’t. You can put the connection string in the config file and pass that into the Connect to Database activity.

@supriya117 I tried it didn’t workout you can see below image

@Srini84 Yes I have printed

It is printing like “UiPath.Database.DatabaseConnection”

@postwick I tried to apply through config but no use.

Thanks for replaying

@uipath @Anil_G @Yoichi @Gokul001 @Gokul_Jayakumar @supermanPunch

@ManjunathReddy

Try this in dbconnection field

in_Config("DBConnection").Cast(Of UIPath.DataBase.DatabaseConnection)

Cheers

It’s not working

find the reference image in the below.

Thanks

Hi,

How about the following?

 CType(in_Config("DBConnection"),UiPath.Database.DatabaseConnection)

Regards,

@ManjunathReddy

Try ctype(in_Config("DBConnection"),Uipath.database.Databaseconnection)

Cheers

@Yoichi @Anil_G

Thanks

@ManjunathReddy

Where are you using this…this has to be used in the place where you are trying to use the connection and not in connect to database activity

in connect to database just give the variable…and when using in existingconnection field use as specified above

cheers

Like below this is in Init state from here I need to tack the connection Name & I have to use in process state where I am executing the query.

Hi,

Can you try the following?

in_Config("DBConnection")

And if you need to restore it to DBConnection type , please use the following.

CType(in_Config("DBConnection"),UiPath.Database.DatabaseConnection)

OR

set DBConnection type variable

Regards,

@ManjunathReddy

in this init application just add the variable as you previously added…and the assign of DBconnection to in_config(“DbConnection”) also will still be there
No change
image

in the process where you want to use the connection…there use the expression give above in the existing connection property

Change here
image

Hope this is clear

cheers

Hello, there is a discussion identical to yours, which was solved (DirectCast(Config(“conn”),DatabaseConnection) ) at: REFramework storing a Database connection in the Config

You don’t put it into the connection property. You put it into the Connection String property.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.