コード例 #1
0
ファイル: UserDataBase.cs プロジェクト: KaushikScorpion/CMS
        public int Register(UserDataObject userObj)
        {//SET DETAILS BEGINS
            int result = 0;

            try
            {
                CMSLogger.SetProperties("AuthToken", "unassigned", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString());
                CMSLogger.log.Info("registerInvoked");

                Conn.Open();
                MySqlCommand cmd;
                cmd             = new MySqlCommand("registeruser", Conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@username", userObj.UserName);
                cmd.Parameters.AddWithValue("@dob", userObj.Dob);
                cmd.Parameters.AddWithValue("@gender", userObj.Gender);
                cmd.Parameters.AddWithValue("@phone", userObj.Phone);
                cmd.Parameters.AddWithValue("@address", userObj.Address);
                cmd.Parameters.AddWithValue("@city", userObj.City);
                cmd.Parameters.AddWithValue("@emailid", userObj.Emailid);
                cmd.Parameters.AddWithValue("@password", userObj.Password);
                result = cmd.ExecuteNonQuery();

                Console.WriteLine("num of rows affected" + result);

                Conn.Close();
            }
            catch (Exception ex)
            {
                CMSLogger.SetProperties("AuthToken", "unassigned", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString());
                CMSLogger.log.Error(ex.Message, ex);
                Conn.Close();
                throw;
            }
            return(result);
        }//SET DETAILS END