コード例 #1
0
        /// <summary>
        /// Execute DataSet with query directly passed as parameter
        /// </summary>
        /// <param name="sSelectSQL">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 sSelectSQL, ArrayList colParameterList)
        {
            // implementation code here...
            SqlConnection     conSQL = new SqlConnection();
            SqlCommand        cmdSQL = new SqlCommand();
            SqlDataAdapter    daSQL;
            NandanaSqlDataSet oDataSetSQL = new NandanaSqlDataSet();
            NandanaDBRequest  oRequest    = new NandanaDBRequest(sSelectSQL, CommandType.Text, null, colParameterList);

            try
            {
                PrepareCommand(cmdSQL, conSQL, null, oRequest);
                daSQL = new SqlDataAdapter(cmdSQL);
                daSQL.Fill(oDataSetSQL.ReturnedDataSet);
            }
            catch (SqlException ex)
            {
                throw (ex);
            }
            finally
            {
                if (cmdSQL != null)
                {
                    cmdSQL.Parameters.Clear();
                }
                if (conSQL.State == ConnectionState.Open)
                {
                    conSQL.Close();
                }
            }

            return(oDataSetSQL);
        }
コード例 #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...
            SqlConnection     conSQL = new SqlConnection();
            SqlCommand        cmdSQL = new SqlCommand();
            SqlDataAdapter    daSQL;
            NandanaSqlDataSet oDataSetSQL = new NandanaSqlDataSet();
            SqlTransaction    tranSQL     = null;

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

                PrepareCommand(cmdSQL, conSQL, tranSQL, Request);
                daSQL = new SqlDataAdapter(cmdSQL);
                daSQL.Fill(oDataSetSQL.ReturnedDataSet);
            }
            catch (SqlException ex)
            {
                if (conSQL.State == ConnectionState.Open)
                {
                    conSQL.Close();
                }
                throw (ex);
            }
            finally
            {
                if (cmdSQL != null)
                {
                    cmdSQL.Parameters.Clear();
                }
                if ((Request.Transaction == null) && (conSQL.State == ConnectionState.Open))
                {
                    conSQL.Close();
                }
            }

            return(oDataSetSQL);
        }