I believe it "doesn't work" because you do something wrong. If you want a more detailed answer, please provide a more detailed description of what "doesn't work".
In any case, why do you create the dialog before having secured the data from the database? I would have done it the other way around.
Bookmarks