简体   繁体   English

如何为oracle c#创建连接字符串

[英]how to create connection string for oracle c#

i am creating connection string for oracle in c# 我在c#中为oracle创建连接字符串

below is my code 下面是我的代码

 OracleConnection cn = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.5 )(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL)));User Id=nTireoffice ;Password=nTireoffice;");
        DataTable dt = new DataTable();
        string strSql = " select to_number (nvl(max(nvl(Region_ID ,0)),0)+1 ) as No from BO_REGION_MASTER ;";

        cn.Open();

        OracleDataAdapter objSda = new OracleDataAdapter(strSql, cn);

        objSda.Fill(dt);
        string s = dt.Rows[0][0].ToString();

its throwing exception ORA-06413: Connection not open. 抛出异常ORA-06413:连接未打开。

i am using windows 8 enterprises 64 bit os 我正在使用Windows 8企业64位操作系统

thank u... 感谢你...

Have a look here . 看看这里 (This is a very useful site for clues about most ORA errors.) (对于大多数ORA错误,这是一个非常有用的网站。)

It sounds like it could be the folder your executable is in, or the actual name of your executable. 听起来它可能是您的可执行文件所在的文件夹,或者您的可执行文件的实际名称。

PS It would be useful if you could tell us the actual line the error occurs on. PS如果您能告诉我们错误发生的实际行,那将会非常有用。

I've created the connection like this. 我已经创建了这样的连接。

ora_cmd = new OracleCommand();
ora_con = new OracleConnection("Data Source={YOUR_HOST}:{YOUR_PORT}/{YOUR_DB};Persist Security Info=True;User ID={YOUR_ID};Password={YOUR_PASSWORD};Pooling=True;Max Pool Size=200;");
ora_cmd.Connection = ora_con;
ora_connect.Open();

Then use the ora_cmd to executes statements 然后使用ora_cmd执行语句

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM