Such a promise and the breaking of it will not cause you to lose your salvation. God hears and responds to our prayers when we "ask any thing according to his will" (1John 5:14). In addition to this, the Holy Spirit helps our prayers by making "intercession for the saints according to the will of God" (Romans 8:27). That is, He takes our prayers and makes them acceptable to the Father according to the will of God. You prayer was certainly not according to His will. He did not respond to it.
Your promise was foolish because it assumed that you had the power to keep it. But even the Apostle Paul said, "For I know that in me (that is, in my flesh,) dwelleth no good thing: for to will is present with me; but how to perform that which is good I find not. For the good that I would I do not: but the evil which I would not, that I do" (Romans 7:18-19). As hopefully you have now done, Paul learned that he could not trust himself to obey God by the simple force of his will power. He had to have the power of Christ working in him in order to please God.
The Lord will certainly forgive you of your foolish promise and He will certainly not remove His free gift of salvation. If you have been truly saved, then you are still saved. You can rest assured of this.
You also need to understand that you are not the only one to have ever made such a statement. I am presently reading an autobiography of the English Baptist Pastor John Kershaw who lived from 1792 to 1870. After he trusted in the Lord as a young man, he struggled terribly with wanting to go to the horse races of the day. These races were full of all sorts of wickedness and he knew that he should not go. On one occasion, he went boldly in rebellion against God but had no peace and found only misery at the races.
Later, when the talk of the town was about the next day of races, he made this vow to God: "Well, Lord, if I go to the races this week, thou shalt damn my soul and send me to hell." As the day of the races drew closer, the temptation to go grew stronger than ever. As you would guess, when the day came, he went. He did not stay and had no joy in what he saw, but he did go. However, God did not hold his foolish vow against him. He went on to be a pastor of a Baptist church and wrote of his experience almost fifty years later. God is a gracious God who winks at our times of ignorance. He expects us to grow in grace. Therefore, to repeat such promises after we know their danger would probably bring correction. But, even then, He would not cast us away. Please trust in Him and know that He will never leave or forsake you (Hebrews 13:5).