A witness, Lueen Homewood, said store workers grabbed first-aid materials off store shelves to help the grandmother as she cradled the wounded child near the store's pharmacy, The (Columbia) State newspaper reported on its Web site.
The girl was rushed to a hospital in critical condition and was recovering Monday afternoon after surgery, said police department spokesman Brick Lewis. Hospital officials would not release her condition after the operation.
Lewis said the grandmother, Donna Hutto Williamson, has a permit to carry a concealed weapon and the purse containing the small-caliber handgun was in the cart near the child. The 47-year-old Williamson, of Salley, was not immediately charged with a crime.
Williamson, a South Carolina magistrate, was distraught after the shooting, her mother-in-law said.
"The grandmother is just beating herself up," said Inease Williamson, 68. "She is just so upset. Everyone is upset."
Officials said the shooting, which was captured on store surveillance cameras, appeared to be accidental. Lewis said police would not release the video.
The store was closed while police investigated the shooting. It reopened Monday afternoon.
"Everyone at Sam's Club is deeply saddened by today's tragedy," Tara Stewart, state spokeswoman for Wal-Mart and Sam's Club, said in a statement. "Our thoughts and prayers are with the little girl and her family."
Concealed weapons permit holders in South Carolina are not allowed to carry weapons into buildings that prohibit it, or into government buildings, schools and daycare facilities, among other places.
The Sam's Club store does not have a sign prohibiting guns inside.