Example #1
0
        public string Update(UpdateUser u)
        {
            string messege;

            con.Open();
            SqlCommand cmd = new SqlCommand("Update UserTab set Name = @Name, Email = @Email where UserID = @UserID", con);

            cmd.Parameters.AddWithValue("@UserID", u.UID);
            cmd.Parameters.AddWithValue("@Name", u.Name);
            cmd.Parameters.AddWithValue("@Email", u.Email);
            int res = cmd.ExecuteNonQuery();

            if (res == 1)
            {
                messege = "Successfully Updated";
            }
            else
            {
                messege = "Failed to Updated";
            }
            return(messege);
        }
Example #2
0
        public string Update(UpdateUser u)
        {
            string        Message = "";
            SqlConnection con     = new SqlConnection("Data Source=WINDOWS-C8ATAQL;Initial Catalog=CRUD;Persist Security Info=True;User ID=sa; Password=pacitan1");

            con.Open();
            SqlCommand cmd = new SqlCommand("Update UserTab set Name = @Name, Email = @Email where UserID= @UserID", con);

            cmd.Parameters.AddWithValue("@UserID", u.UID);
            cmd.Parameters.AddWithValue("@name", u.Name);
            cmd.Parameters.AddWithValue("@Email", u.Email);
            int res = cmd.ExecuteNonQuery();

            if (res == 1)
            {
                Message = "Successfuly Updated";
            }
            else
            {
                Message = "Failed to Update";
            }
            return(Message);
        }