In the movies, Smeagol has forgotten his own name. Frodo reminds him of it. Frodo got the name from Gandalf. Gandalf got the name from ???
In the books, Gandalf got Smeagol's name from... Smeagol. (I think that happened when the Elves of Lothlorien captured and lost Smeagol.) He never forgot it in the books.