Exemple #1
0
        public static bool ExecSql(string sql)
        {
            SqlDB db = new SqlDB();

            using (System.Data.SqlClient.SqlCommand cmd = db.CreateCmd(sql, "text"))
            {
                db.OpenConn();
                if (cmd.ExecuteNonQuery() <= 0)
                {
                    cmd.Dispose();
                    db.CloseConn();
                    return(false);
                }
                else
                {
                    cmd.Dispose();
                    db.CloseConn();
                    return(true);
                }
            }
        }
Exemple #2
0
        public static int ExecScalarProc(string sql)
        {
            SqlDB db = new SqlDB();

            using (System.Data.SqlClient.SqlCommand cmd = db.CreateCmd(sql, "proc"))
            {
                db.OpenConn();
                int n = Convert.ToInt32(cmd.ExecuteScalar());
                cmd.Dispose();
                db.CloseConn();
                return(n);
            }
        }
Exemple #3
0
        public static bool ExecProc(string sql, IDataParameter[] parameters)
        {
            SqlDB db = new SqlDB();

            using (System.Data.SqlClient.SqlCommand cmd = db.CreateCmd(sql, "proc", parameters))
            {
                db.OpenConn();
                if (cmd.ExecuteNonQuery() <= 0)
                {
                    cmd.Parameters.Clear();
                    cmd.Dispose();
                    db.CloseConn();
                    return(false);
                }
                else
                {
                    cmd.Dispose();
                    db.CloseConn();
                    return(true);
                }
            }
        }
Exemple #4
0
        public static int ExecScalarSql(string sql, IDataParameter[] parameters)
        {
            SqlDB db = new SqlDB();

            using (System.Data.SqlClient.SqlCommand cmd = db.CreateCmd(sql, "text", parameters))
            {
                db.OpenConn();
                int n = Convert.ToInt32(cmd.ExecuteScalar());
                cmd.Parameters.Clear();
                cmd.Dispose();
                db.CloseConn();
                return(n);
            }
        }
Exemple #5
0
        public static System.Data.DataSet GetDataSetProc(string sql, IDataParameter[] parameters)
        {
            SqlDB db = new SqlDB();

            using (System.Data.SqlClient.SqlCommand cmd = db.CreateCmd(sql, "proc", parameters))
            {
                using (System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(cmd))
                {
                    DataSet ds = new DataSet();
                    da.Fill(ds, "table");
                    cmd.Parameters.Clear();
                    cmd.Dispose();
                    da.Dispose();
                    db.CloseConn();
                    return(ds);
                }
            }
        }