Is your demo running in windowed mode, or fullscreen? If it's in fullscreen, then getting smooth animation is easy. You just have to create a back buffer, blit to that instead of the primary surface, and then flip it. DirectX will make sure the flip happens during the vertical refresh.
In windowed mode, it is a little bit more difficult, because you can't use the built-in back buffer and flip method. It sounds like you are already using the most common approach except for one thing. You said you are swapping the secondary buffer with the primary one, and I don't think that's possible with DirectX, so are you using GDI instead? If so, that's probably your problem.
You can find sample code to do what I have just described in a number of places, but if you can't find it or still need help, I can post some here.
[This message has been edited by Myopic Rhino (edited September 08, 1999).]