码迷,mamicode.com
首页 > 数据库 > 详细

2011-03-17免Oracle客户端连远程Oracle的方法

时间:2016-10-15 19:56:05      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

1、http://www.oracle.com/technetwork/topics/winsoft-085727.html上下载对应版本的instanctclinet zip包 34M 解压后92M    若要选择非32位操作系统找http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

2、将包中的9个文件解压到system32目录下

3、添加System.Data.OracleClient引用

4、using System.Data.OracleClient 5、string connectionString = "Data Source=( DESCRIPTION = ( ADDRESS_LIST = ( ADDRESS = ( PROTOCOL = TCP )( HOST = 202.149.225.122 )( PORT = 1521 ) ) )( CONNECT_DATA = ( SERVICE_NAME = pub))); User Id= lahom; Password = jj;Unicode=True;"; //Unicode=True;是保证汉字不出现乱码的关键!!            

OracleConnection cnn = new OracleConnection(connectionString);

cnn.Open();

             OracleCommand cmd = cnn.CreateCommand();

             cmd.CommandText = ("SELECT * from ad");

         OracleDataAdapter myda = new OracleDataAdapter(cmd);

                         DataSet myds = new DataSet();

             myda.Fill(myds);

                         MessageBox.Show(myds.Tables[0].Rows[0].ItemArray[2].ToString());

 

2011-03-17免Oracle客户端连远程Oracle的方法

标签:

原文地址:http://www.cnblogs.com/mol1995/p/5965066.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!