Beispiel #1
0
        private DataSet QueryDataSetExec(QueryContext query)
        {
            SqlDataReader  read    = null;
            SqlCommand     cmd     = null;
            SqlDataAdapter adapter = null;

            try
            {
                this.sqlMutex.WaitOne();
                query.Open();
                cmd     = this.InitCommand(query);
                adapter = new SqlDataAdapter(cmd);
                DataSet datas = new DataSet();
                adapter.Fill(datas);
                adapter.Dispose();
                cmd.Dispose();
                adapter = null;
                query.Close();
                return(datas);
            }
            catch (Exception e)
            {
                query.Close(e);
                throw;
            }
            finally
            {
                if (transac == null)
                {
                    this.Close();
                }
                this.sqlMutex.ReleaseMutex();
            }
        }
Beispiel #2
0
        private object QueryScalarExec(QueryContext query)
        {
            SqlDataReader read = null;
            SqlCommand    cmd  = null;

            try
            {
                this.sqlMutex.WaitOne();
                query.Open();
                cmd = this.InitCommand(query);
                object retourobj = cmd.ExecuteScalar();
                cmd.Dispose();
                query.Close();
                return(retourobj);
            }
            catch (Exception e)
            {
                query.Close(e);
                throw;
            }
            finally
            {
                if (transac == null)
                {
                    this.Close();
                }
                this.sqlMutex.ReleaseMutex();
            }
        }
Beispiel #3
0
        private DataTable QueryExec(QueryContext query)
        {
            SqlDataReader  read    = null;
            SqlCommand     cmd     = null;
            SqlDataAdapter adapter = null;

            try
            {
                this.sqlMutex.WaitOne();
                query.Open();
                cmd = this.InitCommand(query);

                DataTable datas = new DataTable();
                read = cmd.ExecuteReader();
                datas.Load(read);
                read.Close();
                read = null;
                cmd.Dispose();
                if (datas != null)
                {
                    query.CountResult = datas.Rows.Count;
                }
                query.Close();
                return(datas);
            }
            catch (Exception e)
            {
                query.Close(e);
                throw;
            }
            finally
            {
                if (transac == null)
                {
                    this.Close();
                }
                this.sqlMutex.ReleaseMutex();
            }
        }