Exemplo n.º 1
0
        public static VTable_Base Select(string tablename, IDbCommand aSelectCommand, IDatabaseConfig _DatabaseConfig)
        {
            VTable_Base tmp = new VTable_Base(tablename, false);
            IDbDataAdapter aDp = _DatabaseConfig.GetHandler().getDataAdapter(aSelectCommand);

            try
            {
                aDp.SelectCommand.Connection.Close();
                aDp.SelectCommand.Connection.Open();
               // aDp.Fill(tmp.Table);
                //	aDp.SelectCommand.Connection.Close();
                if (aDp is MySql.Data.MySqlClient.MySqlDataAdapter)
                    ((MySql.Data.MySqlClient.MySqlDataAdapter)aDp).Fill(tmp.Table);

                if (aDp is System.Data.SqlClient.SqlDataAdapter)
                    ((System.Data.SqlClient.SqlDataAdapter)aDp).Fill(tmp.Table);

                if (aDp is System.Data.OleDb.OleDbDataAdapter)
                    ((System.Data.OleDb.OleDbDataAdapter)aDp).Fill(tmp.Table);
            }
            catch (Exception Ex)
            {
                Logger.LogWriter.Write(Ex.Message);
            }
            finally
            {
                aDp.SelectCommand.Connection.Close();
            }
            return tmp;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Define datatable structure.
        /// </summary>
        /// <param name="SqlTableName"></param>
        /// <param name="aDatabaseConfig"></param>
        /// <param name="bEnableFieldDelimiter"></param>
        public void Setup(string SqlTableName, IDatabaseConfig aDatabaseConfig, bool bEnableFieldDelimiter)
        {
            _SQLTableName = SqlTableName;
            _DatabaseConfig = aDatabaseConfig;
            _DBConn = _DatabaseConfig.GetHandler().getDataConnection();
            _EnableFieldDelimiter = bEnableFieldDelimiter;
            _BeginDelimiterChar = aDatabaseConfig.GetHandler().getFieldBeginDelimiter();
            _EndDelimiterChar = aDatabaseConfig.GetHandler().getFieldEndDelimiter();

            if (_EnableVC)
            {
                _ADP = _DatabaseConfig.GetHandler().getDataAdapter("Select " + GetSQLFields() + " from " + _SQLTableName + " where VC_State = 'Approved'", _DBConn);
            }
            else
            {
                _ADP = _DatabaseConfig.GetHandler().getDataAdapter("Select " + GetSQLFields() + " from " + _SQLTableName, _DBConn);

            }
                //new SqlDataAdapter("Select "+ GetSQLFields() +" from "+_SQLTableName+" where VC_State = 'Approved'", _DBConn);

            // Create Own Update, insert and Delete commands
            //_Builder = new SqlCommandBuilder(_ADP);
            // replace the update command
            _ADP.UpdateCommand = BuildUpdate(_DBConn);
            _ADP.DeleteCommand = BuildDelete(_DBConn);
            _ADP.InsertCommand = BuildInsert(_DBConn);
        }