What is the exact format of a connection string for Oracle?

蹲街弑〆低调 提交于 2019-12-13 08:41:57

问题


I have this code:

string conStr = @"server=ORACLE1001;database=Test;uid=admin;pwd=1234";
mycon = new OleDbConnection();
mycon.ConnectionString = ConStr;

and it throws exception that provider must be like "Provider=SQLOLEDB;" so I tried with conStr = "Provider=OraOLEDB.Oracle.1;server=ORACLE1001;database=Test;uid=admin;pwd=1234; and it throwed exception "ORA-12560: TNS:protocol adapter error" - anny ideas how to fix this? Any ideas what is wrong with my conStr?


回答1:


Please follow the steps and then you will never worry about connection strings for any DBs(including access and excel)!

(1) create a new empty foo.txt

(2) rename it to foo.udl

(3) double click the file, you will see a wizard, with a few tabs and options

(4) do what you want, at last click OK

(5) open foo.udl with notepad(or rename it back to foo.txt)

(6) you can see the most standard connection string in the world



来源:https://stackoverflow.com/questions/5076524/what-is-the-exact-format-of-a-connection-string-for-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!