Beispiel #1
0
        public Boolean Open(string aDataSource, string aUserID, string aPassWord)
        {
            this.m_DataSource = aDataSource;
            this.m_UserID     = aUserID;
            this.m_Password   = aPassWord;
            bool state = false;

            state = m_DBHelper.Open(aDataSource, aUserID, aPassWord);

            if (state)
            {
                DataTable dtCharSet = this.ExecuteDataTable(@"SELECT VALUE FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER = 'NLS_CHARACTERSET'");

                if (dtCharSet.Rows.Count > 0)
                {
                    if (dtCharSet.Rows[0][0].ToString().Equals("US7ASCII"))
                    {
                        m_DBHelper.Close();
                        m_DBHelper = new LHJ.DBService.Helper.Oracle_OleDb.clsOleDb();
                        state      = m_DBHelper.Open(aDataSource, aUserID, aPassWord);
                    }
                    else
                    {
                    }
                }
                else
                {
                }
            }

            return(state);
        }
Beispiel #2
0
        //app.config初始化
        private void button6_Click(object sender, EventArgs e)
        {
            IDBHelper dbhelper = DBHelperManager.GetHelper("mysql");

            try
            {
                dataGridView1.DataSource = dbhelper.ExecuteQuery("select * from wordlist_1");

//                string sql = @"CREATE TABLE wordlist_1 (
//              id INT(11) NOT NULL AUTO_INCREMENT,
//              word VARCHAR(50) DEFAULT NULL,
//              word_cn VARCHAR(50) DEFAULT NULL,
//              courseid TINYINT(4) DEFAULT NULL,
//              wordtype TINYTEXT,
//              PRIMARY KEY (id))";

//                dbhelper.ExecuteNoQuery(sql);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                dbhelper.Close();
            }
        }
Beispiel #3
0
        /// <summary>
        /// 查询操作
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static DataTable ExecuteQuery(string sql)
        {
            IDBHelper _DBHelper = null;

            try
            {
                _DBHelper = CreateHelper();
                return(_DBHelper.ExecuteQuery(sql));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (_DBHelper != null && !InTransaction)
                {
                    _DBHelper.Close();
                }
            }
        }
Beispiel #4
0
 /// <summary> 关闭数据库连接
 /// </summary>
 public void Close()
 {
     _DBHelper.Close();
 }