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

数据库 oracle 函数

时间:2017-12-05 12:01:12      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:oracl   comm   ons   nbsp   pen   except   jks   apt   man   

        static OracleConnection mQracleConnecting = null;
        public static OracleConnection QracleConnecting
        {
            get
            {
                try
                {
                    if(mQracleConnecting ==null)
                        mQracleConnecting = new OracleConnection(jksg);
                    if (mQracleConnecting.State != ConnectionState.Open)
                        mQracleConnecting.Open();
                    return mQracleConnecting;
                }
                catch (Exception)
                {
                    return null;
                }
            }

        }

        public static DataTable DBGetDataTable(string sql,string conn)
        {
            DataTable dataSet = new DataTable();
            OracleDataAdapter OraDA = new OracleDataAdapter(sql, conn);
            OraDA.Fill(dataSet);
            return dataSet;
        }
        public static DataTable DBGetDataTable(string sql, OracleConnection conn)
        {
            DataTable dataSet = new DataTable();
            OracleDataAdapter OraDA = new OracleDataAdapter(sql, conn);
            OraDA.Fill(dataSet);
            return dataSet;
        }


        // 执行SQL语句,返回所影响的行数   
        public static int ExecuteSQL(string sql)
        {
            int Cmd = 0;
            OracleCommand command = new OracleCommand(sql, QracleConnecting);
            try
            {
                Cmd = command.ExecuteNonQuery();
            }
            catch
            {
            }
            return Cmd;
        } 

        public static int ExecuteSQL_Update(string sql)
        {
            OracleDataAdapter OraDA = new OracleDataAdapter(sql, QracleConnecting);
            return OraDA.UpdateCommand.ExecuteNonQuery();
        }
        public static int ExecuteSQL_Insert(string sql)
        {
            OracleDataAdapter OraDA = new OracleDataAdapter(sql, QracleConnecting);
            return OraDA.InsertCommand.ExecuteNonQuery();
        }

 

数据库 oracle 函数

标签:oracl   comm   ons   nbsp   pen   except   jks   apt   man   

原文地址:http://www.cnblogs.com/leolzi/p/7985824.html

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