How to set proper path to TNSNAMES file in C# application?

后端 未结 3 713
忘掉有多难
忘掉有多难 2021-01-06 01:52

I have a program in C# that use ODP.NET dlls:

oci.dll, ociw32.dll, Oracle.DataAccess.dll,
orannzsbb11.dll, oraocci11.dll, oraociicus11.dll,
OraOps11w.dll. 
<         


        
3条回答
  •  鱼传尺愫
    2021-01-06 02:23

    You can set the TNS_ADMIN environment variable programmatically. See this page for a step by step. That is if you wanted to change to a specific TNS_NAMES.ORA file. The Oracle Client must still be installed on the client machine.

    From ConnectionStrings - without using TNS:

    Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;
    


    EDIT: Added 3rd option

    Please see this question which could aid you in finding the current location of the client's TNS_NAMES.ORA file - which you could open and modify if you wish (add your own connection if it doesn't exist)

提交回复
热议问题