There are already several good recommendations in response to the situation you are going through, so, I wanted to bring up 2 different thoughts here.
Your mother has dementia. When you say, "I tried to reason with her, explain it, etc. and she said she would never do it again. She would get up from talking with me and go do it after swearing she would never and does not do it anymore.", it says to me that you are trusting her to understand reasoning and not to lie to you. With dementia, she will promise you many things, however, that does not mean she will remember those things when it is time to. Don't take it personally. She may have the best of intentions to do what you ask, but, is truly incapable of following through. With dementia, it doesn't matter how much time has passed since you talked to her about it, whether its 10 minutes or 10 days. Her memory is like that of a child. They forget almost instantly, if not instantly. So, in this instance, you may want to treat her like you would one of your own children when they are being potty trained. You wouldn't expect them to be able do everything they need to do in the toilet correctly. Don't expect her to, either. Yes, that means that you will have to go in with her. It may be difficult at first, on both of you, but, try to stay calm and patient. Explain why you are in there with her and that you are doing it for hers and your protection. Very important to just remain calm, even when she yells. You may want to make sure there is no lock on the bathroom door that she uses, also, just in case she goes in and you haven't noticed at first.
Secondly, I found in taking care of my mother-in-law that she loved her doctor and would listen to him and follow his advice, when prompted to do so. So, when she raised a fuss about anything, from taking her medicines to staying in bed because she was having a weak day, all I had to say was that her doctor wanted her to do it and she almost always accepted that. I would make it a point to talk to her doctor, in front of her, about the concerns so that she did hear it coming from him directly, at first. How is your mother's relationship with her doctor? Does she trust and like him? I would bring this topic up again at her next appointment and have him tell her in detail why she should not be doing this and what the effects are and how unfair this is to both her and you. Try not to lay blame on her about lying to you and such, especially in front of other people. That is almost always going to anger anyone, especially someone with dementia. Let her know, while your with the doctor, in a concerned, loving voice that you are trying to help her and that you need her to help you with that.
Okay...I think that covers what I wanted to say. You didn't say how long you have been taking care of your mother or what stage of dementia she is in. I'm not trying to preach to you, at all. I am just giving to give you advice on what I have learned about dementia because of my mother-in-law. I hope this helps you. Please let us know. I will keep you in my thoughts and prayers.