最简洁的orcle连接

 /// <summary>
        /// 提取数据
        /// </summary>
        /// <returns></returns>
        private DataTable getOracle()
        {
            //连接数据库
            string ConnectionString = "Data Source=RF_A1_EDM;user=edmadmin;password=edm123;";//写连接串

            string sqlStr = "select * from CD_WELL_SOURCE t  where t.update_date between sysdate-300 and sysdate";
            DataTable dt = new DataTable();
            OracleConnection conn = new OracleConnection(ConnectionString);//创建一个新连接
            try
            {
                conn.Open();
                OracleCommand cmd = new OracleCommand(sqlStr, conn);
                OracleDataAdapter ad = new OracleDataAdapter(cmd);               
                ad.Fill(dt);
            }
            catch (Exception ee)
            {
                //Response.Write(ee.Message); //如果有错误,输出错误信息
            }
            finally
            {
                conn.Close(); //关闭连接
            }          
           
            return dt;
        }

你可能感兴趣的:(最简洁的orcle连接)