示例#1
0
文件: Helper.cs 项目: weimingtom/pap2
        public static int ExecuteCommand(string sql, SqlConnection conn)
        {
            int nRet = 1;

            if (Program.EnableRemoting && false)
            {
                nRet = mDataTableProxy.ExecuteCommand(string.Empty, sql);
            }
            else
            {
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                try
                {
                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandText = sql;
                    nRet            = cmd.ExecuteNonQuery();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    conn.Close();
                }
            }
            return(nRet);
        }