Example #1
0
        public override async Task ExecuteAsync()
        {
            ConnectionState prevState = mConn.State;

            if (prevState != ConnectionState.Open)
            {
                await mConn.OpenAsync();
            }
            if (mDA.SelectCommand == null)
            {
                mDA.SelectCommand = new SqlCommand(SQL, mConn.AdoCon);
            }
            mDS    = new DataSet();
            mState = RSState.Executing;
            //mDA.Fill(mDS, "Result");
            Task t = Task.Run(() => mDA.Fill(mDS, "Result"));

            t.Wait();
            //await Task.Run(()=> mDA.Fill(mDS, "Result"));
            MoveFirst();
            mState = RSState.Open;
            if (prevState != ConnectionState.Open)
            {
                mConn.Close();
            }
        }
Example #2
0
        public override async Task ExecuteAsync()
        {
            ConnectionState prevState = mConn.State;

            if (prevState != ConnectionState.Open)
            {
                await mConn.OpenAsync();
            }
            Cmd = new SqlCommand(SQL, mConn.AdoCon);
            Cmd.CommandTimeout = 300;
            mState             = RSState.Executing;
            try
            {
                mDR = await Cmd.ExecuteReaderAsync();

                dT = new DataTable();
                await Task.Run(() => dT.Load(mDR));

                Result = dT.Rows.OfType <DataRow>().ToList();
                EOF    = RecordCount == 0;
                Index  = 0;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


            mState = RSState.Open;
            if (prevState != ConnectionState.Open)
            {
                mConn.Close();
            }
            Index = 0;
        }