Example #1
0
        /// <summary>
        /// Execute DataSet with query directly passed as parameter
        /// </summary>
        /// <param name="sSelectMySql">Select Query</param>
        /// <param name="colParameterList">Array of NandanaDBRequest.Parameter containing Name and value pair</param>
        /// <returns>DataSet Object</returns>
        public override NandanaDataSet ExecuteDataSet(string sSelectMySql, ArrayList colParameterList)
        {
            // implementation code here...
            MySqlConnection     conMySql = new MySqlConnection();
            MySqlCommand        cmdMySql = new MySqlCommand();
            MySqlDataAdapter    daMySql;
            NandanaMySqlDataSet oDataSetMySql = new NandanaMySqlDataSet();
            NandanaDBRequest    oRequest      = new NandanaDBRequest(sSelectMySql, CommandType.Text, null, colParameterList);

            try
            {
                PrepareCommand(cmdMySql, conMySql, null, oRequest);
                daMySql = new MySqlDataAdapter(cmdMySql);
                daMySql.Fill(oDataSetMySql.ReturnedDataSet);
            }
            catch (MySqlException ex)
            {
                throw (ex);
            }
            finally
            {
                if (cmdMySql != null)
                {
                    cmdMySql.Parameters.Clear();
                }
                if (conMySql.State == ConnectionState.Open)
                {
                    conMySql.Close();
                }
            }

            return(oDataSetMySql);
        }
Example #2
0
        /// <summary>
        /// Execute DataSet
        /// </summary>
        /// <param name="Request">NandanaDBRequest with connection details</param>
        /// <returns>DataSet Object</returns>
        public override NandanaDataSet ExecuteDataSet(NandanaDBRequest Request)
        {
            // implementation code here...
            MySqlConnection     conMySql = new MySqlConnection();
            MySqlCommand        cmdMySql = new MySqlCommand();
            MySqlDataAdapter    daMySql;
            NandanaMySqlDataSet oDataSetMySql = new NandanaMySqlDataSet();
            MySqlTransaction    tranMySql     = null;

            try
            {
                if (Request.Transaction != null)
                {
                    tranMySql = Request.Transaction;
                }

                PrepareCommand(cmdMySql, conMySql, tranMySql, Request);
                daMySql = new MySqlDataAdapter(cmdMySql);
                daMySql.Fill(oDataSetMySql.ReturnedDataSet);
            }
            catch (MySqlException ex)
            {
                if (conMySql.State == ConnectionState.Open)
                {
                    conMySql.Close();
                }
                throw (ex);
            }
            finally
            {
                if (cmdMySql != null)
                {
                    cmdMySql.Parameters.Clear();
                }
                if ((Request.Transaction == null) && (conMySql.State == ConnectionState.Open))
                {
                    conMySql.Close();
                }
            }

            return(oDataSetMySql);
        }