How to connect to Oracle Database using string variable coming from context file

Hello,
I’m doing a library for connect to all my different database using context file. my library gets all information in those context file and set them in string.

I’m actuallly trying to use theirs string in the connect activity but it doesn’t works. How can i do that ?

Here is my connection string :
“USER ID=”+ SLogin +";PASSWORD="+SPassword+";DATA SOURCE="(DESCRIPTION =
(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = SServer )(PORT = SPort )))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = SSid )))""

And here is the error :
image

Did someone know how to solve it ? thanks :slight_smile:

Hello @Gauthier_LEFEVRE,

I think you have a problem with your double quote. At the beginning you have this type “and then you are this ". Try replacing double quote at the beginning with ".

Hi @Gauthier_LEFEVRE

Can you please use the below Connection String and let me know if that works.

SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SServer)(PORT=SPort))(CONNECT_DATA=(SERVICE_NAME=SSid))); uid=[USERNAME];pwd=[PASSWORD];

Please replace the values accordingly.

Happy Automation.

Hi, thanks for replying, this is really appreciate.

@Pierre_Fleury i’ve tried, but it seems to just be reformat for the website, it havn’t change anything.

@suraj.setty I’ve tried it to, but still got an issue. It expecte end of the instruction when typing the “uid” variable. maybe i do not do it well ? not sur about this. I attached a screenshot.

Can you please Assign the connection string to an string variable and pass the variable here , and let me know if that works.

Or if you are passing your username and password through variables , please try the below.

“SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SServer)(PORT=SPort))(CONNECT_DATA=(SERVICE_NAME=SSid))); uid=[USERNAME];pwd=[PASSWORD];”.Replace("[USERNAME]",str_UserName).Replace("[PASSWORD]",str_Password)

Where str_UserName and str_Password are the variables.

Thanks.

Well now i don’t have error on the Connect activity, but on the Execute Request Activity i use for test.

Here is the parameters and error. ( “connexion” is the output of the Connect activity, and the error is " Execute the query: The value cannot be null.
Parameter Name: At least one of the connections must be used."

But i when i use the same parameters and request in another test project with connection working without variables, there is no problem. So i supposed connection to database do not work aswell

I’ve solve the issue.

issue come from two problem :

  • First was some of my variables inclu line break.

  • The second one came from a bad synthaxe in my string. i modified it like this :

“USER ID=”+ SLogin +";PASSWORD="+SPassword+";DATA SOURCE=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = “+SServer+” )(PORT = “+SPort+” )))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = “+SSid+” )))"

Thanks to everyone for your help.

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