示例#1
0
        public static DataTable Select()
        {
            SqlQuery q = new SqlQuery();
            q.CommandText = string.Format(@" select 1");
            q.CommandType = CommandType.Text;

            return SqlDataAccess.ExecuteDataset(q, connupCollect).Tables[0];
        }
示例#2
0
        /// <summary>
        /// SyncParameter
        /// </summary>
        private void SyncParameter(SqlCommand cmd, SqlQuery q)
        {
            //int parameterCount = q.Parameters.Count;
            //if (parameterCount > 0)
            //{
            //    for (int i = 0; i < parameterCount; i++)
            //    {
            //        q.Parameters[i].SyncParameter();
            //    }

            //}
        }
示例#3
0
        /// <summary>
        /// ����Sql����
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="q"></param>
        private void PrepareCommand(SqlCommand cmd, SqlQuery q)
        {
            cmd.CommandType = q.CommandType;
            cmd.CommandText = q.CommandText;
            cmd.Connection = m_Connection;
            cmd.CommandTimeout = q.CommandTimeout;
            cmd.Transaction = m_Trans;

            if (q.Parameters.Count > 0)
            {
                int parameterNum = q.Parameters.Count;
                for (int i = 0; i < parameterNum; i++)
                {
                    cmd.Parameters.Add(q.Parameters[i]);
                }
            }
        }
示例#4
0
        /// <summary>
        /// ִ���������XmlReader
        /// </summary>
        public XmlReader ExecuteXmlReader(SqlQuery q)
        {
            SqlCommand cmd = new SqlCommand();
            PrepareCommand(cmd, q);

            XmlReader xmlReader = cmd.ExecuteXmlReader();

            SyncParameter(cmd, q);

            cmd.Parameters.Clear();

            return xmlReader;
        }
示例#5
0
 /// <summary>
 ///ִ���������Xml����
 /// </summary>
 public XmlDocument ExecuteXmlDoc(SqlQuery q)
 {
     throw new NotImplementedException();
 }
示例#6
0
        /// <summary>
        /// ִ���������������������(Object)
        /// </summary>
        public Object ExecuteScalar(SqlQuery q)
        {
            SqlCommand cmd = new SqlCommand();
            PrepareCommand(cmd, q);

            Object oValue = cmd.ExecuteScalar();

            SyncParameter(cmd, q);

            cmd.Parameters.Clear();

            return oValue;
        }
示例#7
0
        /// <summary>
        /// ִ���������DataReader
        /// </summary>
        public IDataReader ExecuteReader(SqlQuery q)
        {
            SqlCommand cmd = new SqlCommand();
            PrepareCommand(cmd, q);

            IDataReader reader = cmd.ExecuteReader();

            SyncParameter(cmd, q);

            cmd.Parameters.Clear();

            return reader;
        }
示例#8
0
        /// <summary>
        /// ִ���������Ӱ������
        /// </summary>
        public int ExecuteNonQuery(SqlQuery q)
        {
            SqlCommand cmd = new SqlCommand();
            PrepareCommand(cmd, q);

            int affectRows = cmd.ExecuteNonQuery();

            SyncParameter(cmd, q);

            cmd.Parameters.Clear();

            return affectRows;
        }
示例#9
0
        /// <summary>
        /// ִ���������DataSet
        /// Execute query and return DataSet.
        /// </summary>
        public DataSet ExecuteDataset(SqlQuery q)
        {
            DataSet ds = new DataSet();
            SqlCommand cmd = new SqlCommand();
            PrepareCommand(cmd, q);

            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(ds);

            SyncParameter(cmd, q);

            cmd.Parameters.Clear();

            return ds;
        }
示例#10
0
 /// <summary>
 /// ִ���������XmlReader
 /// </summary>
 /// <param name="q">SqlQuery����</param>
 /// <param name="dp">Sql��������</param>
 /// <returns>XmlReader</returns>
 public static XmlReader ExecuteXmlReader(SqlQuery q, DatabaseProperty dp)
 {
     SqlDataAccess da = new SqlDataAccess(dp.ConnectionString);
     da.Open();
     return da.ExecuteXmlReader(q);
 }
示例#11
0
        /// <summary>
        /// ִ���������Xml�ĵ�
        /// </summary>
        /// <param name="q">SqlQuery����</param>
        /// <param name="dp">Sql��������</param>
        /// <returns>Xml�ĵ�</returns>
        public static XmlDocument ExecuteXmlDoc(SqlQuery q, DatabaseProperty dp)
        {
            SqlDataAccess da = new SqlDataAccess(dp.ConnectionString);
            da.Open();
            XmlDocument doc = da.ExecuteXmlDoc(q);
            da.Close();

            return doc;
        }
示例#12
0
        /// <summary>
        /// ִ����������������е�Object
        /// </summary>
        /// <param name="q">SqlQuery����</param>
        /// <param name="dp">Sql��������</param>
        /// <returns>�������е�Object</returns>
        public static Object ExecuteScalar(SqlQuery q, DatabaseProperty dp)
        {
            SqlDataAccess da = new SqlDataAccess(dp.ConnectionString);
            da.Open();
            object scalar = da.ExecuteScalar(q);
            da.Close();

            return scalar;
        }
示例#13
0
        /// <summary>
        /// ִ���������Ӱ������
        /// </summary>
        /// <param name="q">SqlQuery����</param>
        /// <param name="dp">Sql��������</param>
        /// <returns>Ӱ������</returns>
        public static int ExecuteNonQuery(SqlQuery q, DatabaseProperty dp)
        {
            SqlDataAccess da = new SqlDataAccess(dp.ConnectionString);
            da.Open();
            int affectRows = da.ExecuteNonQuery(q);
            da.Close();

            return affectRows;
        }
示例#14
0
        /// <summary>
        /// ִ���������Dataset
        /// </summary>
        /// <param name="q">SqlQuery����</param>
        /// <param name="dp">Sql��������</param>
        /// <returns>Dataset</returns>
        public static DataSet ExecuteDataset(SqlQuery q, DatabaseProperty dp)
        {
            SqlDataAccess da = new SqlDataAccess(dp.ConnectionString);
            da.Open();
            DataSet ds = da.ExecuteDataset(q);
            da.Close();

            return ds;
        }
示例#15
0
        /// <summary>
        /// �õ���¼������ͳ��
        /// </summary>
        /// <returns>RecordCount</returns>
        private int GetRecordCount()
        {
            int posFrom = this.m_CommandText.IndexOf(" FROM ");
            int posOrder = this.m_CommandText.IndexOf(" ORDER ");

            SqlQuery q = new SqlQuery();
            if (posOrder > 0)
                q.CommandText = "SELECT COUNT(1) " + this.m_CommandText.Substring(posFrom, posOrder - posFrom).Trim();
            else
                q.CommandText = "SELECT COUNT(1) " + this.m_CommandText.Substring(posFrom);

            q.Parameters = this.m_Parameters;

            Object recordCount = m_DataAccess.ExecuteScalar(q);

            return (int)recordCount;
        }