.net连接Oracle数据库

准备工作:

下载并引用Oracle.ManagedDataAccess.Client

控制台测试程序

 class Program
    {
        static void Main(string[] args)
        {
            string constr = @"User Id=zftest;Password=123456;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.16.84)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)))";
            DataSet ds = OracleHelper.ExecuteDataset(constr, CommandType.Text, "select *from dba_users");
            DataTable dt = ds.Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {

                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    Console.WriteLine(dt.Rows[i][j]);
                }
                Console.WriteLine("\n");
            }
            //int a=  OracleHelper.ExecuteNonQuery(constr, CommandType.Text, "select *from dba_users");

            int b = 0;


        }
    }

下面是OracleHelper 程序,参数是连接字符串和sql语句。

http://www.cnblogs.com/jimcsharp/p/5590076.html

你可能感兴趣的:(.net连接Oracle数据库)