Ejemplo n.º 1
0
        public void UpdateUserInfo(DataModule.UserInfo userInfo)
        {
            string sql = "UPDATE Tb_UserInfo set Email=@Email, NickName=@NickName, Sex=@Sex, BirthDay=@BirthDay, Age=@Age where UserID=@UserID";

            SqlParameter[] parms = SqlHelperParameterCache.GetCachedParameterSet(sql);
            if (parms == null)
            {
                parms = new SqlParameter[] {
                    new SqlParameter("@Email", SqlDbType.NVarChar, 50),
                    new SqlParameter("@NickName", SqlDbType.NVarChar, 20),
                    new SqlParameter("@Sex", SqlDbType.SmallInt),
                    new SqlParameter("@BirthDay", SqlDbType.Date),
                    new SqlParameter("@Age", SqlDbType.Int),
                    new SqlParameter("@UserID", SqlDbType.BigInt)
                };
                SqlHelperParameterCache.CacheParameterSet(sql, parms);
            }

            parms[0].Value = userInfo.Email;
            parms[1].Value = userInfo.NickName;
            parms[2].Value = userInfo.Sex;
            parms[3].Value = userInfo.BirthDay;
            parms[4].Value = userInfo.Age;
            parms[5].Value = userInfo.UserID;

            SqlHelper.ExecuteNonQuery(connString, CommandType.Text, sql, parms);
        }
Ejemplo n.º 2
0
        public void InsertUserInfo(DataModule.UserInfo userInfo)
        {
            string sql = "INSERT INTO Tb_UserInfo (UserID, Email, NickName, Sex, BirthDay, Age) values (@UserID, @Email, @NickName, @Sex, @BirthDay, @Age)";

            SqlParameter[] parms = SqlHelperParameterCache.GetCachedParameterSet(sql);
            if (parms == null)
            {
                parms = new SqlParameter[] {
                    new SqlParameter("@UserID", SqlDbType.BigInt),
                    new SqlParameter("@Email", SqlDbType.NVarChar, 50),
                    new SqlParameter("@NickName", SqlDbType.NVarChar, 20),
                    new SqlParameter("@Sex", SqlDbType.SmallInt),
                    new SqlParameter("@BirthDay", SqlDbType.Date),
                    new SqlParameter("@Age", SqlDbType.Int)
                };
                SqlHelperParameterCache.CacheParameterSet(sql, parms);
            }

            SqlHelper.ExecuteNonQuery(connString, CommandType.Text, sql, parms);
        }