]使用asp.net访问Oracle的方法汇总
Posted By:/baojin溡緔灬獨/憨居 Date:2014/3/9 18:52:12 最后修改:2014/3/9 18:52:12 Click Rate:297

方法一:通过System.Data.OracleClient(需要安装Oracle客户端并配置tnsnames.ora)

string strcnn = "User ID=lportal;Password=lportal;Data Source=zhbrserverORCL;";

System.Data.OracleClient.OracleConnection cnn = new System.Data.OracleClient.OracleConnection(strcnn);

cnn.Open();

MessageBox.Show(cnn.State.ToString());

cnn.Close();

方法二:通过System.Data.OracleClient(需要安装Oracle客户端不需配置tnsnames.ora)

string strcnn = "User ID=lportal;Password=lportal;Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = zhbrserver)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))";

System.Data.OracleClient.OracleConnection cnn = new System.Data.OracleClient.OracleConnection(strcnn);

cnn.Open();

MessageBox.Show(cnn.State.ToString());

cnn.Close();

方法三:通过System.Data.OleDb和Oracle公司的驱动

string strcnn = "Provider=OraOLEDB.Oracle.1;User ID=lportal;Password=lportal;Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = zhbrserver)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))";

System.Data.OleDb.OleDbConnection cnn = new System.Data.OleDb.OleDbConnection(strcnn);

cnn.Open();

MessageBox.Show(cnn.State.ToString());

cnn.Close();

方法四:通过System.Data.OleDb和微软公司的Oracle驱动

string strcnn = "Provider=MSDAORA.1;User ID=lportal;Password=lportal;Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = zhbrserver)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))";

System.Data.OleDb.OleDbConnection cnn = new System.Data.OleDb.OleDbConnection(strcnn);

cnn.Open();

MessageBox.Show(cnn.State.ToString());

cnn.Close();

备注:

1、   XP操作系统已经安装了微软公司的Oracle驱动C:"Program Files"Common Files"System"Ole DB"msdaora.dll

2、   该驱动需要Oracle客户端的三个文件(oraocixe10.dll、oci.dll、ociw32.dll)方在System32下即可

====================================================


标签: ]使用asp.net访问Oracle的方法汇总
摘要:]使用asp.net访问Oracle的方法汇总


收录查询 Copyright ? 2024  广西佳馨科技   地址:广西佳馨科技  电话:13878876479   QQ:120947546  电子邮件:1447876499@qq.com   站点提供API   桂ICP备14003626号-1
关闭 X