Example #1
0
        /// <summary>
        /// 执行SQL语句
        /// </summary>
        /// <param name="cmdText">执行命令</param>
        /// <param name="lists">SqlParameter集合</param>
        /// <param name="tableName">表名</param>
        /// <returns>自定义类型</returns>
        public ZwhBase ExecuteZB(string cmdText, List<SqlParameter> lists, string tableName)
        {
            ZwhBase zb = new ZwhBase();

            try
            {
                SqlCommand command = GetSqlComand(cmdText);
                if (lists != null)
                {
                    foreach (SqlParameter sp in lists)
                    {
                        if (sp != null && sp.Value != null)
                        {
                            command.Parameters.Add(sp);
                        }
                    }
                }
                SqlDataAdapter sda = new SqlDataAdapter(command);
                zb.ZSet = new DataSet();
                zb.ZLong = sda.Fill(zb.ZSet);
                if (zb.ZInt > 0)
                {
                    zb.ZBool = true;
                }
                if (zb.ZSet != null && zb.ZSet.Tables.Count > 0)
                {
                    if (!string.IsNullOrEmpty(tableName))
                    {
                        zTable = zb.ZSet.Tables[tableName];
                    }
                    else
                    {
                        zTable = zb.ZSet.Tables[0];
                    }
                }
            }
            catch { }

            Close();

            return zb;
        }
Example #2
0
        /// <summary>
        /// 执行SQL语句
        /// </summary>
        /// <param name="cmdText">执行命令</param>
        /// <returns>自定义类型</returns>
        public ZwhBase ExecuteZBDT(string cmdText)
        {
            ZwhBase zb = new ZwhBase();

            try
            {
                List<SqlParameter> lists = null;
                zb = ExecuteZBDT(cmdText, lists);
            }
            catch { }

            Close();

            return zb;
        }
Example #3
0
        /// <summary>
        /// 执行SQL语句
        /// </summary>
        /// <param name="cmdText">执行命令</param>
        /// <param name="lists">SqlParameter集合</param>
        /// <returns>自定义类型</returns>
        public ZwhBase ExecuteZBDT(string cmdText, List<SqlParameter> lists)
        {
            ZwhBase zb = new ZwhBase();

            try
            {
                SqlCommand command = GetSqlComand(cmdText);
                if (lists != null)
                {
                    foreach (SqlParameter sp in lists)
                    {
                        if (sp != null && sp.Value != null)
                        {
                            command.Parameters.Add(sp);
                        }
                    }
                }
                SqlDataAdapter sda = new SqlDataAdapter(command);
                zb.ZTable = new DataTable();
                zb.ZLong = sda.Fill(zb.ZTable);
            }
            catch { }

            Close();

            return zb;
        }
Example #4
0
        /// <summary>
        /// 存在
        /// </summary>
        /// <param name="cmdText">执行命令</param>
        /// <param name="lists">SqlParameter集合</param>
        /// <returns>自定义类型</returns>
        public ZwhBase Exists(string cmdText, List<SqlParameter> lists)
        {
            ZwhBase zb = new ZwhBase();

            try
            {
                SqlCommand command = GetSqlComand(cmdText);
                if (lists != null)
                {
                    foreach (SqlParameter sp in lists)
                    {
                        if (sp != null && sp.Value != null)
                        {
                            command.Parameters.Add(sp);
                        }
                    }
                }
                zObject = command.ExecuteScalar();
                if (zObject != null)
                {
                    zb.ZObject = zObject;
                    zb.ZBool = true;
                }
            }
            catch { }

            Close();

            return zb;
        }